oceanproc 1.3.2__tar.gz → 1.3.3__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.
Files changed (21) hide show
  1. {oceanproc-1.3.2 → oceanproc-1.3.3}/PKG-INFO +1 -1
  2. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/ocean_proc.py +4 -2
  3. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/preprocessing_wrapper.py +42 -37
  4. {oceanproc-1.3.2 → oceanproc-1.3.3}/pyproject.toml +1 -1
  5. {oceanproc-1.3.2 → oceanproc-1.3.3}/README.md +0 -0
  6. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/__init__.py +0 -0
  7. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/bids_wrapper.py +0 -0
  8. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/events_long.py +0 -0
  9. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/firstlevel/__init__.py +0 -0
  10. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/firstlevel/run_glm.py +0 -0
  11. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/firstlevel/tests/__init__.py +0 -0
  12. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/firstlevel/tests/test_run_glm.py +0 -0
  13. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/group_series.py +0 -0
  14. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/grouplevel/__init__.py +0 -0
  15. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/grouplevel/computations.py +0 -0
  16. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/grouplevel/design_mat_utils.py +0 -0
  17. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/grouplevel/dscalar_utils.py +0 -0
  18. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/grouplevel/utils.py +0 -0
  19. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/oceanparse.py +0 -0
  20. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/segmentation_wrapper.py +0 -0
  21. {oceanproc-1.3.2 → oceanproc-1.3.3}/oceanproc/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oceanproc
3
- Version: 1.3.2
3
+ Version: 1.3.3
4
4
  Summary: MRI preprocessing for WUSTL Ocean labs
5
5
  Author-Email: Ramone Agard <rhagard@wustl.edu>, Joey Scanga <joeyscanga92@gmail.com>
6
6
  Requires-Python: <3.13,>=3.10
@@ -103,7 +103,7 @@ def main():
103
103
  epilog="An arguments file can be accepted with @FILEPATH.\nAny additional arguments not listed in the help message will be passed to the preprocessing subprocess.",
104
104
  allow_abbrev=False
105
105
  )
106
- parser.add_argument("--version", action="version", version='%(prog)s v1.3.2')
106
+ parser.add_argument("--version", action="version", version='%(prog)s v1.3.3')
107
107
  session_args = parser.add_argument_group("Session Specific")
108
108
  config_args = parser.add_argument_group("Configuration Arguments", "These arguments are saved to a file if the '--export_args' option is used")
109
109
 
@@ -159,6 +159,8 @@ def main():
159
159
  help="Specifies skipping BIDS validation (only enabled for fMRIprep step)")
160
160
  config_args.add_argument("--fs_subjects_dir", "--fs-subjects-dir", "-fs", type=ExistingDir, dest="fs_subjects_dir",
161
161
  help="The path to the directory that contains previous FreeSurfer outputs/derivatives to use for fMRIPrep. If empty, this is the path where new FreeSurfer outputs will be stored.")
162
+ config_args.add_argument("--topup_config", "--topup-config", "-tc", type=ExistingFile, dest="topup_config",
163
+ help="Path to a TOPUP config file.")
162
164
  config_args.add_argument("--allow_uneven_fmap_groups", action="store_true",
163
165
  help="Flag to allow for automated fieldmap pairing when there's more AP- than PA-encoded fieldmaps, or vice versa (will still error out if at least one of each is not present.)")
164
166
  config_args.add_argument("--extract_best_fmap", action=argparse.BooleanOptionalAction,
@@ -296,7 +298,7 @@ def main():
296
298
  ignore_list = ["tmp_dcm2bids"]
297
299
  if (bids_path / ".bidsignore").is_file():
298
300
  with open(bids_path / ".bidsignore", "r") as f:
299
- ignore_list.extend(f.readlines())
301
+ ignore_list.extend([l.strip() for l in f.readlines()])
300
302
  ignore_list = list(set(ignore_list))
301
303
  other_sub_paths = [
302
304
  p.name for p in bids_path.glob("sub-*")
@@ -32,8 +32,12 @@ infant_defaults = SimpleNamespace(
32
32
  )
33
33
 
34
34
  # Preprocessing arguments that need to have their paths binded when running docker
35
- mount_opts = {"fs_subjects_dir",
36
- "derivatives"}
35
+ mount_opts = {
36
+ "fs_subjects_dir",
37
+ "derivatives",
38
+ "topup_config"
39
+ }
40
+
37
41
 
38
42
  @debug_logging
39
43
  def run_preprocessing(subject:str,
@@ -69,7 +73,7 @@ def run_preprocessing(subject:str,
69
73
  :raise RuntimeError: If preprocessing throws an error, or exits with a non-zero exit code.
70
74
  """
71
75
  def clean_up(): return shutil.rmtree(work_path) if remove_work_folder else None
72
-
76
+
73
77
  log_linebreak()
74
78
  logger.info(f"####### Starting {title} #######\n")
75
79
  if not bids_path.exists():
@@ -81,15 +85,15 @@ def run_preprocessing(subject:str,
81
85
  bids_mount = "/data"
82
86
  derivs_mount = "/out"
83
87
  work_mount = "/work"
84
-
88
+
85
89
  if flags.apptainer:
86
90
  cmd_prelude = f"apptainer run --nv --cleanenv --no-mount cwd --pwd {work_mount}"
87
91
  mount_flag = "-B"
88
- else:
92
+ else:
89
93
  cmd_prelude = f"docker run --rm -i -u {flags.uid}:{flags.gid}"
90
94
  import grp
91
95
  mygids = (
92
- grp.getgrnam(groupname).gr_gid for groupname in
96
+ grp.getgrnam(groupname).gr_gid for groupname in
93
97
  subprocess.run('groups', capture_output=True).stdout.decode().strip().split()
94
98
  )
95
99
  for mygid in mygids:
@@ -126,7 +130,7 @@ def run_preprocessing(subject:str,
126
130
  -w {work_mount} --verbose
127
131
  {additional_mount_args}
128
132
  {option_chain}"""
129
-
133
+
130
134
  success = True
131
135
  try:
132
136
  run_subprocess(preproc_command, title=title)
@@ -140,6 +144,7 @@ def run_preprocessing(subject:str,
140
144
 
141
145
  return success
142
146
 
147
+
143
148
  @debug_logging
144
149
  def add_fd_plot_to_report(subject:str,
145
150
  session:str,
@@ -230,7 +235,7 @@ def add_fd_plot_to_report(subject:str,
230
235
  # Add the new elements into the file
231
236
  logger.debug(f" inserting the new html elements into the {title} report")
232
237
  confounds_plot_div.insert_after(fd_plot_div)
233
- else:
238
+ else:
234
239
  confounds_plot_reference_div = confounds_plot_div.find_next_sibling("div", class_="elem-filename")
235
240
  fd_plot_reference_div = copy.copy(confounds_plot_reference_div)
236
241
  fd_plot_reference_div.a["href"] = "./" + rel_path
@@ -252,9 +257,9 @@ def insert_dummy_frames(subject:str,
252
257
  session:str,
253
258
  dscan_dir:Path,
254
259
  bids_layout:BIDSLayout):
255
-
260
+
256
261
  dscans_suffix = "dscans"
257
- dscans_path_pattern = "sub-{subject}[/ses-{session}]/{datatype<func|meg|beh>|func}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_rec-{reconstruction}][_run-{run}][_echo-{echo}][_recording-{recording}]_{suffix<"+dscans_suffix+">}{extension<.tsv|.json>|.tsv}"
262
+ dscans_path_pattern = "sub-{subject}[/ses-{session}]/{datatype<func|meg|beh>|func}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_rec-{reconstruction}][_run-{run}][_echo-{echo}][_recording-{recording}]_{suffix<" + dscans_suffix + ">}{extension<.tsv|.json>|.tsv}"
258
263
 
259
264
  log_linebreak()
260
265
  logger.info(f"####### Inserting Dummy Scans #######\n")
@@ -306,27 +311,27 @@ def insert_dummy_frames(subject:str,
306
311
  frame_list = []
307
312
  dscans_index = 0
308
313
  for f in range(num_bold_frames):
309
- copy_dex = f-1 if f > 0 else f
314
+ copy_dex = f - 1 if f > 0 else f
310
315
  while dscans_list[dscans_index] != 0:
311
316
  frame_list.append(bold_data[:,:,:,copy_dex])
312
317
  dscans_index += 1
313
318
  frame_list.append(bold_data[:,:,:,f])
314
319
  dscans_index += 1
315
320
  # check if end of run needs to be extended
316
- if (f == num_bold_frames-1) and (dscans_index < len(dscans_list)):
321
+ if (f == num_bold_frames - 1) and (dscans_index < len(dscans_list)):
317
322
  while dscans_index < len(dscans_list):
318
323
  frame_list.append(bold_data[:,:,:,f])
319
324
  dscans_index += 1
320
325
 
321
326
  if len(frame_list) != len(dscans_list):
322
327
  exit_program_early(f"Something went wrong when creating dummy scans, lengths do not match. bold frames: {len(frame_list)}, dscan length: {len(dscans_list)}")
323
-
328
+
324
329
  # save new image
325
330
  extended_bold_data = np.stack(frame_list, axis=3)
326
331
  extended_bold_img = bold_img.__class__(extended_bold_data, header=bold_img.header, affine=bold_img.affine)
327
332
  logger.info(f" saving extended bold image")
328
333
  nib.save(extended_bold_img, bfile.path)
329
-
334
+
330
335
 
331
336
  @debug_logging
332
337
  def process_data(subject:str,
@@ -364,23 +369,23 @@ def process_data(subject:str,
364
369
  preproc_title = "NiBabies" if flags.infant else "fMRIPrep"
365
370
 
366
371
  preproc_success = run_preprocessing(subject=subject,
367
- session=session if flags.infant else None,
368
- bids_path=bids_path,
369
- derivs_path=derivs_path,
370
- work_path=work_path,
371
- license_file=license_file,
372
- image_name=image_name,
373
- title=preproc_title,
374
- option_chain=option_chain,
375
- additional_mounts=additional_mounts,
376
- remove_work_folder=remove_work_folder)
377
-
372
+ session=session if flags.infant else None,
373
+ bids_path=bids_path,
374
+ derivs_path=derivs_path,
375
+ work_path=work_path,
376
+ license_file=license_file,
377
+ image_name=image_name,
378
+ title=preproc_title,
379
+ option_chain=option_chain,
380
+ additional_mounts=additional_mounts,
381
+ remove_work_folder=remove_work_folder)
382
+
378
383
  if preproc_success:
379
384
  add_fd_plot_to_report(subject=subject,
380
- session=session,
381
- derivs_path=derivs_path,
382
- title=preproc_title)
383
-
385
+ session=session,
386
+ derivs_path=derivs_path,
387
+ title=preproc_title)
388
+
384
389
  paths_to_update = []
385
390
  paths_to_update.extend(sorted(derivs_path.glob(f"sub-{subject}*")))
386
391
  paths_to_update.extend(sorted(derivs_path.glob(f"sourcedata/*/sub-{subject}*")))
@@ -388,14 +393,14 @@ def process_data(subject:str,
388
393
  if out_path.exists():
389
394
  # update file permissions for preprocessing outputs
390
395
  update_permissions(
391
- permissions=flags.file_permissions,
392
- path=out_path,
396
+ permissions=flags.file_permissions,
397
+ path=out_path,
393
398
  recursive=True,
394
399
  group=flags.permissions_group
395
400
  )
396
-
401
+
397
402
  # check other top-level files
398
- other_paths = [derivs_path/"dataset_description.json", derivs_path/"logs"]
403
+ other_paths = [derivs_path / "dataset_description.json", derivs_path / "logs"]
399
404
  for op in other_paths:
400
405
  if op.exists() and (op.stat().st_uid == flags.uid):
401
406
  update_permissions(
@@ -404,15 +409,15 @@ def process_data(subject:str,
404
409
  recursive=True,
405
410
  group=flags.permissions_group
406
411
  )
407
-
412
+
408
413
  # update file permisions for working directory files
409
414
  update_permissions(
410
- permissions=flags.file_permissions,
411
- path=work_path,
415
+ permissions=flags.file_permissions,
416
+ path=work_path,
412
417
  recursive=True,
413
418
  group=flags.permissions_group,
414
419
  quiet=True
415
420
  )
416
-
421
+
417
422
  if not preproc_success:
418
423
  exit_program_early(f"Program '{preproc_title}' has run into an error.")
@@ -34,7 +34,7 @@ dependencies = [
34
34
  "pybids>=0.16.3",
35
35
  ]
36
36
  name = "oceanproc"
37
- version = "1.3.2"
37
+ version = "1.3.3"
38
38
  description = "MRI preprocessing for WUSTL Ocean labs"
39
39
  readme = "README.md"
40
40
 
File without changes
File without changes