Skip to content

Commit

Permalink
Updated file structure, added registration of TFL maps
Browse files Browse the repository at this point in the history
  • Loading branch information
jcohenadad committed Dec 22, 2023
1 parent 0cb5b12 commit 8d583b7
Showing 1 changed file with 70 additions and 22 deletions.
92 changes: 70 additions & 22 deletions Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,43 @@
"\n",
"The data can be download at: XXX (TODO: upload on openneuro)\n",
"\n",
"The structure of the input dataset is as follows:\n",
"The structure of the input dataset is as follows (JSON sidecars are not listed for clarity):\n",
"~~~\n",
"RF_shimming_project_cleanupload/\n",
"├── SubA\n",
"│   ├── GRE_B1\n",
"│   │   ├── CVred\n",
"│   │   ├── Noshim\n",
"│   │   ├── PatSpec\n",
"│   │   ├── PhaseOnly\n",
"│   │   ├── SAReff\n",
"│   │   ├── Target\n",
"│   │   └── VolSpec\n",
"│   └── MPRAGE\n",
"├── SubB\n",
"├── SubC\n",
"├── SubD\n",
"└── SubE\n",
"├── CHANGES\n",
"├── README\n",
"├── dataset_description.json\n",
"├── participants.json\n",
"├── participants.tsv\n",
"├── sub-01\n",
"│   ├── anat\n",
"│   │   ├── sub-01_acq-CP_T1w.nii.gz\n",
"│   │   ├── sub-01_acq-CP_T2starw.nii.gz\n",
"│   │   ├── sub-01_acq-CoV_T1w.nii.gz\n",
"│   │   ├── sub-01_acq-CoV_T2starw.nii.gz\n",
"│   │   ├── sub-01_acq-SAReff_T2starw.nii.gz\n",
"│   │   ├── sub-01_acq-patient_T2starw.nii.gz\n",
"│   │   ├── sub-01_acq-phase_T2starw.nii.gz\n",
"│   │   ├── sub-01_acq-target_T2starw.nii.gz\n",
"│   │   ├── sub-01_acq-volume_T2starw.nii.gz\n",
"│   └── fmap\n",
"│   ├── sub-01_acq-anatCP_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-anatCoV_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-anatSAReff_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-anatpatient_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-anatphase_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-anattarget_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-anatvolume_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-fampCP_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-fampCoV_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-fampSAReff_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-famppatient_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-fampphase_TB1TFL.nii.gz\n",
"│   ├── sub-01_acq-famptarget_TB1TFL.nii.gz\n",
"│   └── sub-01_acq-fampvolume_TB1TFL.nii.gz\n",
"├── sub-02\n",
"├── sub-03\n",
"├── sub-04\n",
"└── sub-05\n",
"~~~\n",
"\n",
"\n",
Expand Down Expand Up @@ -78,9 +98,22 @@
"!datalad install https://github.com/OpenNeuroDatasets/ds004906.git\n",
"os.chdir(\"ds004906\")\n",
"# !datalad get . # uncomment for production\n",
"!datalad get sub-01/ # comment for debugging\n",
"!datalad get sub-01/ # comment for debugging"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6fe120e8",
"metadata": {},
"outputs": [],
"source": [
"# Define useful variables\n",
"\n",
"path_data = os.getcwd()\n",
"path_qc = os.path.join(path_data, \"qc\")"
"path_qc = os.path.join(path_data, \"qc\")\n",
"shim_modes = [\"CP\", \"CoV\", \"patient\", \"phase\", \"SAReff\", \"target\", \"volume\"]\n",
"subjects = glob.glob(\"sub-*\")"
]
},
{
Expand All @@ -92,15 +125,14 @@
"source": [
"# Run segmentation on GRE scan\n",
"\n",
"subjects = glob.glob(\"sub-*\")\n",
"for subject in subjects:\n",
" os.chdir(os.path.join(path_data, subject, \"anat\"))\n",
" !sct_deepseg_sc -i {subject}_acq-CoV_T2starw.nii.gz -c t2 -qc {path_qc}"
]
},
{
"cell_type": "markdown",
"id": "49c57187",
"id": "aac9d889",
"metadata": {},
"source": [
"## Verify quality control (QC) report\n",
Expand All @@ -111,15 +143,31 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1809bb43",
"id": "90deb5e5",
"metadata": {},
"outputs": [],
"source": [
"# Crop GRE scan for faster processing and better registration results\n",
"\n",
"for subject in subjects:\n",
" os.chdir(os.path.join(path_data, subject, \"anat\"))\n",
" !sct_crop_image -i {subject}_acq-CoV_T2starw.nii.gz -m {subject}_acq-CoV_T2starw_seg.nii.gz -dilate 20x20x0 -o {subject}_acq-CoV_T2starw_crop.nii.gz\n",
" !sct_crop_image -i {subject}_acq-CoV_T2starw_seg.nii.gz -m {subject}_acq-CoV_T2starw_seg.nii.gz -dilate 20x20x0 -o {subject}_acq-CoV_T2starw_crop_seg.nii.gz"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e0cde907",
"metadata": {},
"outputs": [],
"source": [
"# Register TFL B1maps to the GRE scan\n",
"\n",
"for subject in subjects:\n",
" os.chdir(os.path.join(path_data, subject, \"fmap\"))\n",
" !sct_register_multimodal -i {subject}_acq-anatCoV_TB1TFL.nii.gz -d ../anat/{subject}_acq-CoV_T2starw.nii.gz -param step=1,type=im,algo=slicereg,metric=CC -qc {path_qc}"
" for shim_mode in shim_modes:\n",
" !sct_register_multimodal -i {subject}_acq-anat{shim_mode}_TB1TFL.nii.gz -d ../anat/{subject}_acq-CoV_T2starw_crop.nii.gz -dseg ../anat/{subject}_acq-CoV_T2starw_crop_seg.nii.gz -param step=1,type=im,algo=slicereg,metric=CC -qc {path_qc}"
]
}
],
Expand Down

0 comments on commit 8d583b7

Please sign in to comment.