Skip to content

Commit

Permalink
[ENH] Enable debugging in converters (#1186)
Browse files Browse the repository at this point in the history
* update adni to bids

* update aibl to bids

* update oasis to bids
  • Loading branch information
NicolasGensollen authored May 22, 2024
1 parent fc406ad commit 60f168b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
15 changes: 9 additions & 6 deletions clinica/iotools/converters/adni_to_bids/adni_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1296,13 +1296,16 @@ def paths_to_bids(

bids_dir = Path(bids_dir)
images_list = list([data for _, data in images.iterrows()])
create_file_ = partial(
create_file,
modality=modality,
bids_dir=bids_dir,
mod_to_update=mod_to_update,
)
# If n_procs==1 do not rely on a Process Pool to enable classical debugging
if n_procs == 1:
return [create_file_(image) for image in images_list]
with Pool(processes=n_procs) as pool:
create_file_ = partial(
create_file,
modality=modality,
bids_dir=bids_dir,
mod_to_update=mod_to_update,
)
output_file_treated = pool.map(create_file_, images_list)

return output_file_treated
Expand Down
16 changes: 9 additions & 7 deletions clinica/iotools/converters/aibl_to_bids/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,16 @@ def paths_to_bids(
)

images_list = list([data for _, data in images.iterrows()])

create_file_ = partial(
_create_file,
modality=modality,
bids_dir=bids_dir,
overwrite=overwrite,
)
# If n_procs==1 do not rely on a Process Pool to enable classical debugging
if n_procs == 1:
return [create_file_(image) for image in images_list]
with Pool(processes=n_procs) as pool:
create_file_ = partial(
_create_file,
modality=modality,
bids_dir=bids_dir,
overwrite=overwrite,
)
output_file_treated = pool.map(create_file_, images_list)

return output_file_treated
Expand Down
12 changes: 8 additions & 4 deletions clinica/iotools/converters/oasis_to_bids/oasis_to_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ def convert_images(self, source_dir, dest_dir, n_procs: Optional[int] = 1):
for path in Path(source_dir).rglob("OAS1_*")
if path.is_dir() and path.name.endswith("_MR1")
]

with Pool(processes=n_procs) as pool:
func = partial(self.convert_single_subject, dest_dir=dest_dir)
pool.map(func, subjs_folders)
func = partial(self.convert_single_subject, dest_dir=dest_dir)
# If n_procs==1 do not rely on a Process Pool to enable classical debugging
if n_procs == 1:
for folder in subjs_folders:
func(folder)
else:
with Pool(processes=n_procs) as pool:
pool.map(func, subjs_folders)

0 comments on commit 60f168b

Please sign in to comment.