Skip to content

Commit

Permalink
Add example for BIDS dataset in tutorial notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
sinhaharsh committed Feb 5, 2024
1 parent 72d7986 commit a17b8c1
Showing 1 changed file with 96 additions and 3 deletions.
99 changes: 96 additions & 3 deletions docs/usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2023-10-12T19:27:37.395592028Z",
"start_time": "2023-10-12T19:27:36.813565194Z"
"end_time": "2024-02-05T02:47:03.236451813Z",
"start_time": "2024-02-05T02:46:52.707102319Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -366,6 +366,99 @@
}
}
},
{
"cell_type": "markdown",
"source": [
"## A similar example with BIDS dataset would be:"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
}
],
"source": [
"import zipfile\n",
"MRdataset_root = Path(__name__).resolve().parents[1]\n",
"DATA_ARCHIVE = MRdataset_root / 'MRdataset/tests/resources/example_bids_data.zip'\n",
"DATA_ROOT = Path('/tmp/')\n",
"with zipfile.ZipFile(DATA_ARCHIVE, 'r') as zip_ref:\n",
" zip_ref.extractall(DATA_ROOT)\n",
"print((DATA_ROOT/'example_bids_dataset').exists())\n",
"bids_dataset = import_dataset(data_source=DATA_ROOT/'example_bids_dataset',\n",
" ds_format='bids')"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-05T02:50:18.509122234Z",
"start_time": "2024-02-05T02:50:17.116480480Z"
}
},
"execution_count": 8
},
{
"cell_type": "code",
"outputs": [
{
"data": {
"text/plain": "6 subjects with 542 sessions in total"
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bids_dataset"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-05T02:50:19.656918419Z",
"start_time": "2024-02-05T02:50:19.650049515Z"
}
},
"execution_count": 9
},
{
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Subject: sub-02,\n",
"Session: ses-perceptionLetterImage01,\n",
"Run: run-01,\n",
"Sequence: func(SPP=InvalidType,SPLS=InvalidType,TR=2.0,FC=InvalidType,SHM=InvalidType,PF=InvalidType,PATM=InvalidType,SSEQ=InvalidType,SEQV=InvalidType,DT=InvalidType,SHS=InvalidType,MRAT=InvalidType,WCWE=InvalidType,PFD=InvalidType,TCN=InvalidType,AF=InvalidType,MFS=3.0,WC=InvalidType,IOP=InvalidType,SBS=InvalidType,PAT=InvalidType,FOV=InvalidType,PS=InvalidType,PHPL=InvalidType,NAV=InvalidType,IPP=InvalidType,PPFOV=InvalidType,NLGC=InvalidType,HB=InvalidType,TI=InvalidType,MTCS=InvalidType,RCAE=InvalidType,SV=InvalidType,ST=InvalidType,PP=InvalidType,RCN=InvalidType,MAF=InvalidType,SCOP=InvalidType,IF=InvalidType,BPE=InvalidType,SQNM=InvalidType,MTS=InvalidType,BA=InvalidType,VFAF=InvalidType,ETL=InvalidType,IN=InvalidType,WW=InvalidType,SIPV=InvalidType,ACQM=InvalidType,PPCSD=InvalidType,PED=InvalidType,PES=InvalidType,MSM=InvalidType,SR=InvalidType,SMD=InvalidType,CS=InvalidType,MFR=SIEMENS,MMN=VERIO,GM=InvalidType,LIPV=InvalidType,PR=InvalidType,PBW=InvalidType,PS=InvalidType,BS=InvalidType,IT=InvalidType,R=InvalidType,SL=InvalidType,C=InvalidType,PRFIP=InvalidType,FA=80.0,EN=InvalidType,SAR=InvalidType,PI=InvalidType,TE=[0.043])\n"
]
}
],
"source": [
"seq_name = 'func'\n",
"for subject, session, run, sequence in dicom_dataset.traverse_horizontal(seq_name):\n",
" print(f\"Subject: {subject},\\nSession: {session},\\nRun: {run},\\nSequence: {sequence}\")\n",
" break"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-05T02:57:56.046980815Z",
"start_time": "2024-02-05T02:57:55.988220218Z"
}
},
"execution_count": 13
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit a17b8c1

Please sign in to comment.