|
958 | 958 | "# Co-register subjects across sites for better visualisation\n",
|
959 | 959 | "\n",
|
960 | 960 | "sites = [\"CRMBM\", \"UCL\", \"MNI\", \"MGH\", \"MPI\", \"NTNU\", \"MSSM\"]\n",
|
961 |
| - "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", |
| 961 | + "subject_id = '3' # Subject number to generate figures from\n", |
962 | 962 | "site_ref = 'CRMBM'\n",
|
963 | 963 | "vert_labels = '3' # vertebral levels for alignment between sites\n",
|
964 | 964 | "\n",
|
965 | 965 | "files_anat = [\"acq-anat_TB1TFL\", \"acq-famp_TB1DREAM\",\"acq-coilQaSagLarge_SNR_T0000\"] # image that serves as a reference to get the segmentation\n",
|
966 | 966 | "files_metric = [\"TFLTB1map\", \"DREAMTB1avgB1map\",\"acq-coilQaSagLarge_SNR_T0000\"] # coilQA image to display on the figure\n",
|
967 | 967 | "\n",
|
968 |
| - "for subject_id in subject_ids:\n", |
969 |
| - " for site in sites:\n", |
970 |
| - " print(f\"👉 PROCESSING: {site}{subject_id}\")\n", |
971 |
| - " for file_anat, file_metric in zip(files_anat, files_metric):\n", |
972 |
| - " os.chdir(os.path.join(path_data, \"sub-\"+site+subject_id, \"fmap\"))\n", |
973 |
| - " # Extract vertebral labels\n", |
974 |
| - " !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", |
975 |
| - " # Co-register data to reference subject\n", |
976 |
| - " if site != \"CRMBM\":\n", |
977 |
| - " !sct_register_multimodal \\\n", |
978 |
| - " -i sub-{site}{subject_id}_{file_metric}.nii.gz \\\n", |
979 |
| - " -iseg sub-{site}{subject_id}_{file_anat}_seg.nii.gz \\\n", |
980 |
| - " -ilabel sub-{site}{subject_id}_{file_anat}_labels.nii.gz \\\n", |
981 |
| - " -d ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_metric}.nii.gz \\\n", |
982 |
| - " -dseg ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_anat}_seg.nii.gz \\\n", |
983 |
| - " -dlabel ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_anat}_labels.nii.gz \\\n", |
984 |
| - " -param step=0,type=label,dof=Tx_Ty_Tz:step=1,type=seg,iter=0 \\\n", |
985 |
| - " -x nn" |
| 968 | + "for site in sites:\n", |
| 969 | + " print(f\"👉 PROCESSING: {site}{subject_id}\")\n", |
| 970 | + " for file_anat, file_metric in zip(files_anat, files_metric):\n", |
| 971 | + " os.chdir(os.path.join(path_data, \"sub-\"+site+subject_id, \"fmap\"))\n", |
| 972 | + " # Extract vertebral labels\n", |
| 973 | + " !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", |
| 974 | + " # Co-register data to reference subject\n", |
| 975 | + " if site != \"CRMBM\":\n", |
| 976 | + " !sct_register_multimodal \\\n", |
| 977 | + " -i sub-{site}{subject_id}_{file_metric}.nii.gz \\\n", |
| 978 | + " -iseg sub-{site}{subject_id}_{file_anat}_seg.nii.gz \\\n", |
| 979 | + " -ilabel sub-{site}{subject_id}_{file_anat}_labels.nii.gz \\\n", |
| 980 | + " -d ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_metric}.nii.gz \\\n", |
| 981 | + " -dseg ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_anat}_seg.nii.gz \\\n", |
| 982 | + " -dlabel ../../sub-{site_ref}{subject_id}/fmap/sub-{site_ref}{subject_id}_{file_anat}_labels.nii.gz \\\n", |
| 983 | + " -param step=0,type=label,dof=Tx_Ty_Tz:step=1,type=seg,iter=0 \\\n", |
| 984 | + " -x nn" |
986 | 985 | ]
|
987 | 986 | },
|
988 | 987 | {
|
|
1071 | 1070 | " axes=axes.flatten() \n",
|
1072 | 1071 | " for i,site in enumerate(sites):\n",
|
1073 | 1072 | " # Load data\n",
|
1074 |
| - " os.chdir(os.path.join(path_data, f\"sub-{site}{ind_subject}\", \"fmap\"))\n", |
| 1073 | + " os.chdir(os.path.join(path_data, f\"sub-{site}{subject_id}\", \"fmap\"))\n", |
1075 | 1074 | " if site == site_ref:\n",
|
1076 | 1075 | " suffix = \"\"\n",
|
1077 | 1076 | " else:\n",
|
1078 | 1077 | " suffix = \"_reg\"\n",
|
1079 |
| - " map = nib.load(f\"sub-{site}{ind_subject}_{file_metric}{suffix}_flatten.nii.gz\")\n", |
| 1078 | + " map = nib.load(f\"sub-{site}{subject_id}_{file_metric}{suffix}_flatten.nii.gz\")\n", |
1080 | 1079 | " # map = nib.load(f\"sub-{site}{ind_subject}_{file_metric}{suffix}.nii.gz\")\n",
|
1081 |
| - " slices = slicing_indices[file_metric][ind_subject]\n", |
| 1080 | + " slices = slicing_indices[file_metric][subject_id]\n", |
1082 | 1081 | " data = map.get_fdata()[slices[0], slices[1], round(map.get_fdata().shape[2] / 2)]\n",
|
1083 | 1082 | "\n",
|
1084 | 1083 | " # Figure configuration\n",
|
|
1129 | 1128 | "legend_types = [\"1/g\", \"[arb]\"]\n",
|
1130 | 1129 | "\n",
|
1131 | 1130 | "# Select individual subject to show\n",
|
1132 |
| - "ind_subject = '2'\n", |
| 1131 | + "ind_subject = '2' # Here we select subject 2 because it has the most complete data\n", |
1133 | 1132 | "\n",
|
1134 | 1133 | "mean_gfac = {}\n",
|
1135 | 1134 | "max_gfac = {}\n",
|
|
1223 | 1222 | "sites = [\"CRMBM\", \"UCL\", \"MNI\", \"MGH\", \"MPI\", \"NTNU\", \"MSSM\"]\n",
|
1224 | 1223 | "\n",
|
1225 | 1224 | "# Select subject to show\n",
|
1226 |
| - "subject = '1'\n", |
| 1225 | + "subject = '1' # and here we select subject 1 because it has the most complete data\n", |
1227 | 1226 | "\n",
|
1228 | 1227 | " \n",
|
1229 | 1228 | "for i,site in enumerate(sites):\n",
|
|
0 commit comments