Get label and subject information prior to label splitting.
(label, subject=None, subjects_dir=None)
| 1219 | |
| 1220 | |
| 1221 | def _prep_label_split(label, subject=None, subjects_dir=None): |
| 1222 | """Get label and subject information prior to label splitting.""" |
| 1223 | # If necessary, find the label |
| 1224 | if isinstance(label, BiHemiLabel): |
| 1225 | raise TypeError("Can only split labels restricted to one hemisphere.") |
| 1226 | elif isinstance(label, str): |
| 1227 | label = read_label(label) |
| 1228 | |
| 1229 | # Find the subject |
| 1230 | subjects_dir = str(get_subjects_dir(subjects_dir, raise_error=True)) |
| 1231 | if label.subject is None and subject is None: |
| 1232 | raise ValueError("The subject needs to be specified.") |
| 1233 | elif subject is None: |
| 1234 | subject = label.subject |
| 1235 | elif label.subject is None: |
| 1236 | pass |
| 1237 | elif subject != label.subject: |
| 1238 | raise ValueError( |
| 1239 | f"The label specifies a different subject ({repr(label.subject)}) from " |
| 1240 | f"the subject parameter ({repr(subject)})." |
| 1241 | ) |
| 1242 | |
| 1243 | return label, subject, subjects_dir |
| 1244 | |
| 1245 | |
| 1246 | def _split_label_contig(label_to_split, subject=None, subjects_dir=None): |
no test coverage detected