oceanproc 1.3.3__tar.gz → 1.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {oceanproc-1.3.3 → oceanproc-1.3.4}/PKG-INFO +1 -1
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/bids_wrapper.py +23 -18
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/group_series.py +1 -1
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/ocean_proc.py +11 -11
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/preprocessing_wrapper.py +14 -4
- {oceanproc-1.3.3 → oceanproc-1.3.4}/pyproject.toml +1 -1
- {oceanproc-1.3.3 → oceanproc-1.3.4}/README.md +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/__init__.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/events_long.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/firstlevel/__init__.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/firstlevel/run_glm.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/firstlevel/tests/__init__.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/firstlevel/tests/test_run_glm.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/grouplevel/__init__.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/grouplevel/computations.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/grouplevel/design_mat_utils.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/grouplevel/dscalar_utils.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/grouplevel/utils.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/oceanparse.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/segmentation_wrapper.py +0 -0
- {oceanproc-1.3.3 → oceanproc-1.3.4}/oceanproc/utils.py +0 -0
|
@@ -74,7 +74,8 @@ def run_dcm2bids(subject:str,
|
|
|
74
74
|
bids_output_dir:Path,
|
|
75
75
|
config_file:Path,
|
|
76
76
|
nordic_config:Path = None,
|
|
77
|
-
skip_validate:bool = False
|
|
77
|
+
skip_validate:bool = False,
|
|
78
|
+
keep_part_files: bool = False):
|
|
78
79
|
"""
|
|
79
80
|
Run dcm2bids with a given set of parameters.
|
|
80
81
|
|
|
@@ -128,11 +129,12 @@ def run_dcm2bids(subject:str,
|
|
|
128
129
|
run_subprocess(nordic_run_command, title=title)
|
|
129
130
|
|
|
130
131
|
# Clean up NORDIC files
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
if not keep_part_files:
|
|
133
|
+
separate_nordic_files = bids_output_dir.glob(f"sub-{subject}/ses-{session}/func/*_part-*")
|
|
134
|
+
logger.debug("removing the old nordic files that are not needed after mag-phase combination :")
|
|
135
|
+
for f in separate_nordic_files:
|
|
136
|
+
logger.debug(f"deleting file: {f}")
|
|
137
|
+
os.remove(f)
|
|
136
138
|
|
|
137
139
|
except (Exception, KeyboardInterrupt) as e:
|
|
138
140
|
prepare_subprocess_logging(logger, stop=True)
|
|
@@ -141,6 +143,7 @@ def run_dcm2bids(subject:str,
|
|
|
141
143
|
|
|
142
144
|
return True
|
|
143
145
|
|
|
146
|
+
|
|
144
147
|
@debug_logging
|
|
145
148
|
def run_dcm2niix(source_dir:Path,
|
|
146
149
|
tmp_nifti_dir:Path):
|
|
@@ -178,7 +181,7 @@ def run_dcm2niix(source_dir:Path,
|
|
|
178
181
|
prepare_subprocess_logging(logger, stop=True)
|
|
179
182
|
logger.exception(e, stack_info=True)
|
|
180
183
|
return False
|
|
181
|
-
|
|
184
|
+
|
|
182
185
|
return True
|
|
183
186
|
|
|
184
187
|
|
|
@@ -271,7 +274,7 @@ def extend_session(subject:str,
|
|
|
271
274
|
continue
|
|
272
275
|
run_nums = [f.entities['run'] for f in similar_files if 'run' in f.entities]
|
|
273
276
|
max_bids_run = 1 if len(run_nums) == 0 else int(max(run_nums))
|
|
274
|
-
tmp_ent['run'] = f"{(max_bids_run+tmp_run_num):02d}"
|
|
277
|
+
tmp_ent['run'] = f"{(max_bids_run + tmp_run_num):02d}"
|
|
275
278
|
tmp_new_path = bids_layout.build_path(tmp_ent)
|
|
276
279
|
logger.info(f"moving file: {tmp_file.path} to: {tmp_new_path}")
|
|
277
280
|
shutil.move(tmp_file.path, tmp_new_path)
|
|
@@ -297,7 +300,8 @@ def dicom_to_bids(subject:str,
|
|
|
297
300
|
skip_validate:bool = False,
|
|
298
301
|
skip_prompt:bool = False,
|
|
299
302
|
session_index:int = 0,
|
|
300
|
-
keep_all_niftis:bool = False
|
|
303
|
+
keep_all_niftis:bool = False,
|
|
304
|
+
keep_part_files:bool = False):
|
|
301
305
|
"""
|
|
302
306
|
Facilitates the conversion of DICOM data into NIFTI data in BIDS format, and the removal of data marked 'unusable'.
|
|
303
307
|
|
|
@@ -350,7 +354,7 @@ def dicom_to_bids(subject:str,
|
|
|
350
354
|
nii_success = run_dcm2niix(source_dir=source_dir,
|
|
351
355
|
tmp_nifti_dir=tmp_nifti_path)
|
|
352
356
|
else:
|
|
353
|
-
# copy current niftis to tmp_nifti_path
|
|
357
|
+
# copy current niftis to tmp_nifti_path
|
|
354
358
|
logger.info(f"copying the source NIFTI files to tmp directory, {tmp_nifti_path}")
|
|
355
359
|
shutil.copytree(source_dir.resolve(), tmp_nifti_path.resolve())
|
|
356
360
|
|
|
@@ -361,7 +365,7 @@ def dicom_to_bids(subject:str,
|
|
|
361
365
|
recursive=True,
|
|
362
366
|
group=flags.permissions_group
|
|
363
367
|
)
|
|
364
|
-
|
|
368
|
+
|
|
365
369
|
if not nii_success:
|
|
366
370
|
exit_program_early(f"Problem running 'dcm2niix'")
|
|
367
371
|
|
|
@@ -408,13 +412,14 @@ def dicom_to_bids(subject:str,
|
|
|
408
412
|
session_number=session_index)
|
|
409
413
|
|
|
410
414
|
dcm2bids_success = run_dcm2bids(subject=subject,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
415
|
+
session=session,
|
|
416
|
+
nifti_dir=tmp_nifti_path,
|
|
417
|
+
bids_output_dir=bids_dir,
|
|
418
|
+
config_file=bids_config,
|
|
419
|
+
nordic_config=nordic_config,
|
|
420
|
+
skip_validate=skip_validate,
|
|
421
|
+
keep_part_files=keep_part_files)
|
|
422
|
+
|
|
418
423
|
update_permissions(
|
|
419
424
|
permissions=flags.file_permissions,
|
|
420
425
|
path=sub_ses_bids_dir,
|
|
@@ -50,7 +50,7 @@ def get_func_from_bids(bids_layout: BIDSLayout,
|
|
|
50
50
|
session:str,
|
|
51
51
|
groupings: list[dict[str:set]]):
|
|
52
52
|
|
|
53
|
-
func_files = bids_layout.get(subject=subject, session=session, suffix="bold", datatype="func", extension="nii.gz")
|
|
53
|
+
func_files = bids_layout.get(subject=subject, session=session, suffix="bold", datatype="func", extension=["nii.gz","nii"])
|
|
54
54
|
if len(func_files) == 0:
|
|
55
55
|
exit_program_early("Could not find any functional BOLD files for this subject and session.")
|
|
56
56
|
|
|
@@ -94,7 +94,7 @@ def main():
|
|
|
94
94
|
|
|
95
95
|
default_user_group = grp.getgrgid(os.getgid()).gr_name
|
|
96
96
|
default_file_permissions = "771"
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
parser = OceanParser(
|
|
99
99
|
prog="oceanproc",
|
|
100
100
|
description="Ocean Labs adult MRI preprocessing",
|
|
@@ -141,7 +141,7 @@ def main():
|
|
|
141
141
|
config_args.add_argument("--derivs_path", "-d", type=ExistingDir, required=True,
|
|
142
142
|
help="The path to the BIDS formated derivatives directory for this subject")
|
|
143
143
|
config_args.add_argument("--derivs_subfolder", "-ds", default=None,
|
|
144
|
-
help=f"""The subfolder in the derivatives directory where bids style outputs should be stored.
|
|
144
|
+
help=f"""The subfolder in the derivatives directory where bids style outputs should be stored.
|
|
145
145
|
The default is {adult_defaults.derivs_subfolder} or {infant_defaults.derivs_subfolder} if the '--infant' flag is set.""")
|
|
146
146
|
config_args.add_argument("--bids_config", "-c", type=ExistingFile, required=True,
|
|
147
147
|
help="The path to the dcm2bids config file to use for this subject and session")
|
|
@@ -174,8 +174,10 @@ def main():
|
|
|
174
174
|
help="The path to the working directory used to store intermediate files")
|
|
175
175
|
config_args.add_argument("--fs_license", "--fs-license-file", "-l", type=ExistingFile, dest="fs_license", required=True,
|
|
176
176
|
help="The path to the license file for the local installation of FreeSurfer")
|
|
177
|
+
config_args.add_argument("--keep_part_files", action=argparse.BooleanOptionalAction,
|
|
178
|
+
help="Don't automatically remove 'part-mag' and 'part-phase' files after running dcm2bids.")
|
|
177
179
|
config_args.add_argument("--image_version", "-iv", default=None,
|
|
178
|
-
help=f"""The version of fmriprep to use; It is reccomended that an entire study use the same version.
|
|
180
|
+
help=f"""The version of fmriprep to use; It is reccomended that an entire study use the same version.
|
|
179
181
|
The default is {adult_defaults.image_version} or {infant_defaults.image_version} if the '--infant' flag is set.""")
|
|
180
182
|
config_args.add_argument("--infant", "-I", action=argparse.BooleanOptionalAction,
|
|
181
183
|
help="Flag to specify that NiBabies should be used instead of fMRIPrep")
|
|
@@ -235,7 +237,7 @@ def main():
|
|
|
235
237
|
if args.debug_mode:
|
|
236
238
|
flags.debug = True
|
|
237
239
|
logger.setLevel(logging.DEBUG)
|
|
238
|
-
|
|
240
|
+
|
|
239
241
|
flags.file_permissions = args.file_permissions
|
|
240
242
|
flags.permissions_group = args.permissions_group
|
|
241
243
|
flags.gid = grp.getgrnam(flags.permissions_group).gr_gid
|
|
@@ -255,7 +257,6 @@ def main():
|
|
|
255
257
|
logger.exception(e)
|
|
256
258
|
exit_program_early(e)
|
|
257
259
|
|
|
258
|
-
|
|
259
260
|
# log the input arguments
|
|
260
261
|
for k,v in (dict(args._get_kwargs())).items():
|
|
261
262
|
logger.info(f" {k} : {v}")
|
|
@@ -286,14 +287,15 @@ def main():
|
|
|
286
287
|
skip_validate=args.skip_bids_validation,
|
|
287
288
|
skip_prompt=index > 0,
|
|
288
289
|
session_index=index,
|
|
289
|
-
keep_all_niftis=args.keep_all_niftis
|
|
290
|
+
keep_all_niftis=args.keep_all_niftis,
|
|
291
|
+
keep_part_files=args.keep_part_files
|
|
290
292
|
)
|
|
291
293
|
if index > 0:
|
|
292
294
|
extend_session(subject=args.subject,
|
|
293
295
|
session=args.session,
|
|
294
296
|
tmp_dir=bids_path,
|
|
295
297
|
bids_dir=args.bids_path)
|
|
296
|
-
|
|
298
|
+
|
|
297
299
|
# create a bids layout object
|
|
298
300
|
ignore_list = ["tmp_dcm2bids"]
|
|
299
301
|
if (bids_path / ".bidsignore").is_file():
|
|
@@ -301,8 +303,8 @@ def main():
|
|
|
301
303
|
ignore_list.extend([l.strip() for l in f.readlines()])
|
|
302
304
|
ignore_list = list(set(ignore_list))
|
|
303
305
|
other_sub_paths = [
|
|
304
|
-
|
|
305
|
-
|
|
306
|
+
p.name for p in bids_path.glob("sub-*")
|
|
307
|
+
if not f"sub-{args.subject}".startswith(p.name) and p.is_dir() # 'startswith' to account for pybids regexifying after the end of subject name
|
|
306
308
|
]
|
|
307
309
|
ignore_list.extend(other_sub_paths)
|
|
308
310
|
bids_layout = BIDSLayout(args.bids_path, validate=False, indexer=BIDSLayoutIndexer(ignore=ignore_list, validate=False))
|
|
@@ -354,7 +356,6 @@ def main():
|
|
|
354
356
|
if not bibsnet_path.exists():
|
|
355
357
|
exit_program_early(f"Cannot find the outputs for BIBSnet at the path {bibsnet_path}")
|
|
356
358
|
|
|
357
|
-
|
|
358
359
|
##### Insert dummy scans in requested #####
|
|
359
360
|
if args.dscans_path:
|
|
360
361
|
insert_dummy_frames(
|
|
@@ -364,7 +365,6 @@ def main():
|
|
|
364
365
|
bids_layout=bids_layout
|
|
365
366
|
)
|
|
366
367
|
|
|
367
|
-
|
|
368
368
|
##### Run fMRIPrep or NiBabies #####
|
|
369
369
|
all_opts = dict(args._get_kwargs())
|
|
370
370
|
|
|
@@ -74,6 +74,14 @@ def run_preprocessing(subject:str,
|
|
|
74
74
|
"""
|
|
75
75
|
def clean_up(): return shutil.rmtree(work_path) if remove_work_folder else None
|
|
76
76
|
|
|
77
|
+
def make_mount_path(path_to_mount:str|Path, mount_key:int):
|
|
78
|
+
mount_path = f"/deriv{mount_key}"
|
|
79
|
+
path_to_mount = Path(path_to_mount)
|
|
80
|
+
if path_to_mount.is_file():
|
|
81
|
+
suffix = "".join(path_to_mount.suffixes)
|
|
82
|
+
mount_path += suffix
|
|
83
|
+
return mount_path
|
|
84
|
+
|
|
77
85
|
log_linebreak()
|
|
78
86
|
logger.info(f"####### Starting {title} #######\n")
|
|
79
87
|
if not bids_path.exists():
|
|
@@ -107,12 +115,14 @@ def run_preprocessing(subject:str,
|
|
|
107
115
|
arg_vals = [k]
|
|
108
116
|
if isinstance(v, list):
|
|
109
117
|
for sub_v in v:
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
mount_path = make_mount_path(sub_v, mount_dex)
|
|
119
|
+
additional_mount_paths.append(f"{mount_flag} {sub_v.resolve()}:{mount_path}")
|
|
120
|
+
arg_vals.append(mount_path)
|
|
112
121
|
mount_dex += 1
|
|
113
122
|
else:
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
mount_path = make_mount_path(v, mount_dex)
|
|
124
|
+
additional_mount_paths.append(f"{mount_flag} {v.resolve()}:{mount_path}")
|
|
125
|
+
arg_vals.append(mount_path)
|
|
116
126
|
mount_dex += 1
|
|
117
127
|
additional_mount_args.append(" ".join(arg_vals))
|
|
118
128
|
additional_mount_paths = " ".join(additional_mount_paths)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|