Skip to content

Commit

Permalink
Oasis3 code fetching cross-plateform (#429)
Browse files Browse the repository at this point in the history
* activate the oasis3tobids converter test

* Change variable name in oasis3 converter for clarity

* Change the creation of series for cross platform compatibility

* Delete useless comments and prints

* Fix file_spec_series
  • Loading branch information
MatthieuJoulot committed Sep 21, 2021
1 parent db0ba6f commit 6a6d7e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions clinica/iotools/converters/oasis3_to_bids/oasis3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,31 @@ def read_clinical_data(


def read_imaging_data(imaging_data_directory: PathLike) -> DataFrame:
from pathlib import Path

import pandas as pd

s = pd.Series(find_imaging_data(imaging_data_directory), name="source_path")
source_path_series = pd.Series(
find_imaging_data(imaging_data_directory), name="source_path"
)

source_dir_series = source_path_series.apply(lambda x: Path(str(x)).parent).rename(
"source_dir"
)

b = s.str.rsplit(pat="/", n=1, expand=True).drop(columns=1)[0].rename("source_dir")
a = s.str.split(pat="/", n=1, expand=True).drop(columns=1)[0].rename("path")
df_source = pd.concat([s, a, b, a.str.split("_", expand=True)], axis=1)
file_spec_series = source_path_series.apply(lambda x: Path(str(x)).parts[0]).rename(
"path"
)

df_source = pd.concat(
[
source_path_series,
file_spec_series,
source_dir_series,
file_spec_series.str.split("_", expand=True),
],
axis=1,
)
df_source = df_source.rename(
{0: "Subject", 1: "modality", 2: "Date"}, axis="columns"
).drop_duplicates()
Expand Down
2 changes: 1 addition & 1 deletion test/nonregression/iotools/test_run_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
params=[
"Nifd2Bids",
"Oasis2Bids",
# "Oasis3ToBids",
"Oasis3ToBids",
"Adni2Bids",
"Aibl2Bids",
]
Expand Down

0 comments on commit 6a6d7e8

Please sign in to comment.