Skip to content

Commit

Permalink
Only run generate figure for one subject
Browse files Browse the repository at this point in the history
  • Loading branch information
jcohenadad committed Nov 3, 2024
1 parent fe60935 commit a7e540f
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions data_processing-human.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -958,31 +958,30 @@
"# Co-register subjects across sites for better visualisation\n",
"\n",
"sites = [\"CRMBM\", \"UCL\", \"MNI\", \"MGH\", \"MPI\", \"NTNU\", \"MSSM\"]\n",
"subject_ids = ['3'] # [\"1\",\"2\",\"3\"] JCA: Given that we create a figure showing only subject 3 I think we can skip the others for the sake of time\n",
"subject_id = '3' # Subject number to generate figures from\n",
"site_ref = 'CRMBM'\n",
"vert_labels = '3' # vertebral levels for alignment between sites\n",
"\n",
"files_anat = [\"acq-anat_TB1TFL\", \"acq-famp_TB1DREAM\",\"acq-coilQaSagLarge_SNR_T0000\"] # image that serves as a reference to get the segmentation\n",
"files_metric = [\"TFLTB1map\", \"DREAMTB1avgB1map\",\"acq-coilQaSagLarge_SNR_T0000\"] # coilQA image to display on the figure\n",
"\n",
"for subject_id in subject_ids:\n",
" for site in sites:\n",
" print(f\"👉 PROCESSING: {site}{subject_id}\")\n",
" for file_anat, file_metric in zip(files_anat, files_metric):\n",
" os.chdir(os.path.join(path_data, \"sub-\"+site+subject_id, \"fmap\"))\n",
" # Extract vertebral labels\n",
" !sct_label_utils -i sub-{site}{subject_id}_{file_name}_seg_labeled-UNIT1reg.nii.gz -vert-body {vert_labels} -o sub-{site}{subject_id}_{file_name}_labels.nii.gz\n",
" # Co-register data to reference subject\n",
" if site != \"CRMBM\":\n",
" !sct_register_multimodal \\\n",
" -i sub-{site}{subject_id}_{file_metric}.nii.gz \\\n",
" -iseg sub-{site}{subject_id}_{file_anat}_seg.nii.gz \\\n",
" -ilabel sub-{site}{subject_id}_{file_anat}_labels.nii.gz \\\n",
" -d ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_metric}.nii.gz \\\n",
" -dseg ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_anat}_seg.nii.gz \\\n",
" -dlabel ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_anat}_labels.nii.gz \\\n",
" -param step=0,type=label,dof=Tx_Ty_Tz:step=1,type=seg,iter=0 \\\n",
" -x nn"
"for site in sites:\n",
" print(f\"👉 PROCESSING: {site}{subject_id}\")\n",
" for file_anat, file_metric in zip(files_anat, files_metric):\n",
" os.chdir(os.path.join(path_data, \"sub-\"+site+subject_id, \"fmap\"))\n",
" # Extract vertebral labels\n",
" !sct_label_utils -i sub-{site}{subject_id}_{file_anat}_seg_labeled-UNIT1reg.nii.gz -vert-body {vert_labels} -o sub-{site}{subject_id}_{file_anat}_labels.nii.gz\n",
" # Co-register data to reference subject\n",
" if site != \"CRMBM\":\n",
" !sct_register_multimodal \\\n",
" -i sub-{site}{subject_id}_{file_metric}.nii.gz \\\n",
" -iseg sub-{site}{subject_id}_{file_anat}_seg.nii.gz \\\n",
" -ilabel sub-{site}{subject_id}_{file_anat}_labels.nii.gz \\\n",
" -d ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_metric}.nii.gz \\\n",
" -dseg ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_anat}_seg.nii.gz \\\n",
" -dlabel ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_anat}_labels.nii.gz \\\n",
" -param step=0,type=label,dof=Tx_Ty_Tz:step=1,type=seg,iter=0 \\\n",
" -x nn"
]
},
{
Expand Down Expand Up @@ -1071,14 +1070,14 @@
" axes=axes.flatten() \n",
" for i,site in enumerate(sites):\n",
" # Load data\n",
" os.chdir(os.path.join(path_data, f\"sub-{site}{ind_subject}\", \"fmap\"))\n",
" os.chdir(os.path.join(path_data, f\"sub-{site}{subject_id}\", \"fmap\"))\n",
" if site == site_ref:\n",
" suffix = \"\"\n",
" else:\n",
" suffix = \"_reg\"\n",
" map = nib.load(f\"sub-{site}{ind_subject}_{file_metric}{suffix}_flatten.nii.gz\")\n",
" map = nib.load(f\"sub-{site}{subject_id}_{file_metric}{suffix}_flatten.nii.gz\")\n",
" # map = nib.load(f\"sub-{site}{ind_subject}_{file_metric}{suffix}.nii.gz\")\n",
" slices = slicing_indices[file_metric][ind_subject]\n",
" slices = slicing_indices[file_metric][subject_id]\n",
" data = map.get_fdata()[slices[0], slices[1], round(map.get_fdata().shape[2] / 2)]\n",
"\n",
" # Figure configuration\n",
Expand Down Expand Up @@ -1129,7 +1128,7 @@
"legend_types = [\"1/g\", \"[arb]\"]\n",
"\n",
"# Select individual subject to show\n",
"ind_subject = '2'\n",
"ind_subject = '2' # Here we select subject 2 because it has the most complete data\n",
"\n",
"mean_gfac = {}\n",
"max_gfac = {}\n",
Expand Down Expand Up @@ -1223,7 +1222,7 @@
"sites = [\"CRMBM\", \"UCL\", \"MNI\", \"MGH\", \"MPI\", \"NTNU\", \"MSSM\"]\n",
"\n",
"# Select subject to show\n",
"subject = '1'\n",
"subject = '1' # and here we select subject 1 because it has the most complete data\n",
"\n",
" \n",
"for i,site in enumerate(sites):\n",
Expand Down

0 comments on commit a7e540f

Please sign in to comment.