Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmje committed May 31, 2022
2 parents cd29c90 + 30b44e2 commit 6e5ff74
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 37 deletions.
2 changes: 1 addition & 1 deletion _episodes/scanner-to-computer.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dcm2niix -help
> > ## Solution
> > ~~~
> > mkdir -p ../data/dicom_examples/nii
> > dcm2niix -z y -o ../data/dicom_examples/nii ../data/dicom_examples/0219191_mystudy-0219-1114/dcm
> > dcm2niix -z y -o ../data/dicom_examples/nii ../data/dicom_examples/0219191_mystudy-0219-1114/
> > ~~~
> > {: .language-bash}
> {: .solution}
Expand Down
20 changes: 17 additions & 3 deletions code/01-scanner-to-computer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"solution2": "hidden",
"solution2_first": true
},
"source": [
"<b>EXERCISE:</b> Convert the Princeton DICOM data to NIfTI"
]
Expand All @@ -85,12 +88,23 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"solution2": "hidden"
},
"outputs": [],
"source": [
"%%bash\n",
"\n",
"mkdir -p ../data/dicom_examples/nii\n",
"dcm2niix -z y -o ../data/dicom_examples/nii ../data/dicom_examples/0219191_mystudy-0219-1114/dcm\n",
"rm -fr ../data/dicom_examples/nii/*scout*"
"dcm2niix \\\n",
" -z y \\\n",
" -o ../data/dicom_examples/nii \\\n",
" ../data/dicom_examples/0219191_mystudy-0219-1114/dcm"
]
}
],
Expand Down
63 changes: 59 additions & 4 deletions code/02-anatomy-of-nifti.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@
"<b>EXERCISE:</b> Extract the value of <code>pixdim</code> from <code>t1_hdr</code>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"solution2": "hidden"
},
"outputs": [],
"source": [
"t1_hdr['pixdim']"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -145,7 +156,7 @@
"\n",
"with open(\"../data/dicom_examples/nii/dcm_anat_ses-01_T1w_20190219111436_5.json\", \"r\") as f:\n",
" t1_metadata = json.load(f)\n",
" \n",
"\n",
"t1_metadata"
]
},
Expand All @@ -163,6 +174,17 @@
"<b>EXERCISE:</b> Extract the value of <code>SliceThickness</code> from <code>t1_metadata</code> similar to how you did previously for <code>t1_hdr</code>."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"solution2": "hidden"
},
"outputs": [],
"source": [
"t1_metadata[\"SliceThickness\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -218,6 +240,17 @@
"<b>EXERCISE:</b> Let's check out some *attributes* of the array. How can we see the number of dimensions in the <code>t1_data</code> array? What about the how big each dimension is (shape)? Once again, all of the attributes of the array can be seen by typing `t1_data.` and <kbd>Tab</kbd>."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"solution2": "hidden"
},
"outputs": [],
"source": [
"t1_data.ndim"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -384,7 +417,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"solution2": "hidden"
},
"outputs": [],
"source": [
"y_slice = t1_data[:, 79, :]"
Expand All @@ -400,7 +435,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"solution2": "hidden"
},
"outputs": [],
"source": [
"z_slice = t1_data[:, :, 99]"
Expand All @@ -419,7 +456,7 @@
"source": [
"## Visualizing\n",
"\n",
"We previously inspected the signal intensity of the voxel at coordinates (10,20,3). Let's see what out data looks like when we slice it at this location. We've already indexed the data at each x, y, and z axis. Let's use `matplotlib`."
"We previously inspected the signal intensity of the voxel at coordinates (10,20,3). Let's see what out data looks like when we slice it at this location. We've already indexed the data at each x, y, and z axis. Let's use `matplotlib`, Python's standard plotting library."
]
},
{
Expand Down Expand Up @@ -449,6 +486,24 @@
"plotting.view_img(t1_img, black_bg=True, colorbar=False, cmap=\"gray\", symmetric_cmap=False, vmin=0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"An upgrade from `matplotlib` is `nilearn`, which provides several advanced plotting features for neuroimaging data."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from nilearn import plotting\n",
"\n",
"plotting.view_img(t1_img, black_bg=True, colorbar=False, cmap=\"gray\", symmetric_cmap=False, vmin=0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
58 changes: 54 additions & 4 deletions code/03-data-organization-bids.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"solution2": "hidden",
"solution2_first": true
},
"source": [
"<b>EXERCISE:</b> Let's take a look at the rest of our NIfTI dataset from the last lesson. Imagine you are a collaborator who's currently gotten your hands on this dataset for an analysis. What are some immediate questions you might have that aren't apparent at a first glance?\n",
"\n",
Expand Down Expand Up @@ -44,7 +47,9 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"solution2": "hidden"
},
"source": [
"- How many subjects were scanned?\n",
"- What are the demographics of the participants?\n",
Expand Down Expand Up @@ -82,7 +87,7 @@
"source": [
"## Structure\n",
"\n",
"The current spec https://bids-specification.readthedocs.io/en/stable/\n"
"The current BIDS specification is [documented online](https://bids-specification.readthedocs.io/en/stable/).\n"
]
},
{
Expand Down Expand Up @@ -204,6 +209,51 @@
" -o ../data/dicom_examples/dcm2bids"
]
},
{
"cell_type": "markdown",
"metadata": {
"solution2": "hidden",
"solution2_first": true
},
"source": [
"`Dcm2Bids` uses a configuration file in order to match scans with the appropriate BIDS filename. We will create this file together but it can also be revealed by clicking the toggle below."
]
},
{
"cell_type": "markdown",
"metadata": {
"solution2": "hidden"
},
"source": [
"{\n",
" \"descriptions\": [\n",
" {\n",
" \"dataType\": \"anat\",\n",
" \"modalityLabel\": \"T1w\",\n",
" \"criteria\": { \"SeriesDescription\": \"anat_ses-01_T1w\" }\n",
" },\n",
" {\n",
" \"dataType\": \"func\",\n",
" \"modalityLabel\": \"bold\",\n",
" \"customLabels\": \"task-sound\",\n",
" \"criteria\": { \"SeriesDescription\": \"func_ses-01_task-sound*\" }\n",
" },\n",
" {\n",
" \"dataType\": \"func\",\n",
" \"modalityLabel\": \"bold\",\n",
" \"customLabels\": \"task-story\",\n",
" \"criteria\": { \"SeriesDescription\": \"func_ses-01_task-story*\" }\n",
" },\n",
" {\n",
" \"dataType\": \"func\",\n",
" \"modalityLabel\": \"bold\",\n",
" \"customLabels\": \"task-faces\",\n",
" \"criteria\": { \"SeriesDescription\": \"func_ses-01_task-faces*\" }\n",
" }\n",
" ]\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -216,7 +266,7 @@
"dcm2bids \\\n",
" -d ../data/dicom_examples/0219191_mystudy-0219-1114/dcm \\\n",
" -p 01 -s 01 \\\n",
" -c ../data/dicom_examples/dcm2bids/code/config.json \\\n",
" -c ../data/dicom_examples/dcm2bids/code/bids_config.json \\\n",
" -o ../data/dicom_examples/dcm2bids/rawdata"
]
},
Expand Down
Loading

0 comments on commit 6e5ff74

Please sign in to comment.