Skip to content

Commit

Permalink
Replaced sct_label_vertebrae with sct_label_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jcohenadad committed Dec 23, 2023
1 parent 3c56ddb commit 7e9b051
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions data_processing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@
"\n",
"!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"
"# !datalad get . # uncomment for production\n",
"!datalad get sub-01/ # debugging\n",
"# Get derivatives containing manual labels\n",
"!datalad get derivatives"
]
},
{
Expand All @@ -116,7 +118,8 @@
"\n",
"path_data = os.getcwd()\n",
"path_qc = os.path.join(path_data, \"qc\")\n",
"shim_modes = [\"CP\", \"CoV\", \"patient\", \"phase\", \"SAReff\", \"target\", \"volume\"]\n",
"# shim_modes = [\"CP\", \"CoV\", \"patient\", \"phase\", \"SAReff\", \"target\", \"volume\"]\n",
"shim_modes = [\"CP\", \"CoV\"] # debugging\n",
"subjects = glob.glob(\"sub-*\")"
]
},
Expand Down Expand Up @@ -147,11 +150,16 @@
{
"cell_type": "code",
"execution_count": null,
"id": "95cafe0d",
"id": "862dc562",
"metadata": {},
"outputs": [],
"source": [
"os.path.join(path_data, \"derivatives\", \"labels\", subject, \"anat\", f\"{subject}_acq-CoV_T2starw_label-discs_dseg.nii.gz\")\n"
"# 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"
]
},
{
Expand All @@ -167,23 +175,9 @@
"for subject in subjects:\n",
" os.chdir(os.path.join(path_data, subject, \"anat\"))\n",
" fname_label_discs = os.path.join(path_data, \"derivatives\", \"labels\", subject, \"anat\", f\"{subject}_acq-CoV_T2starw_label-discs_dseg.nii.gz\")\n",
" !sct_label_vertebrae -i {subject}_acq-CoV_T2starw.nii.gz -s {subject}_acq-CoV_T2starw_seg.nii.gz -c t2 -discfile {fname_label_discs} -qc {path_qc}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "862dc562",
"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\n",
" !sct_crop_image -i {subject}_acq-CoV_T2starw_seg_labeled.nii.gz -m {subject}_acq-CoV_T2starw_seg.nii.gz -dilate 20x20x0 -o {subject}_acq-CoV_T2starw_crop_seg_labeled.nii.gz "
" !sct_label_utils -i {subject}_acq-CoV_T2starw_crop_seg.nii.gz -disc {fname_label_discs} -o {subject}_acq-CoV_T2starw_crop_seg_labeled.nii.gz\n",
" # Generate QC report to assess labeled segmentation\n",
" !sct_qc -i {subject}_acq-CoV_T2starw_crop.nii.gz -s {subject}_acq-CoV_T2starw_crop_seg_labeled.nii.gz -p sct_label_vertebrae -qc {path_qc} -qc-subject {subject}"
]
},
{
Expand Down

0 comments on commit 7e9b051

Please sign in to comment.