Skip to content

Commit

Permalink
fix: make load_data more flexible by enable pd.dataframe as input
Browse files Browse the repository at this point in the history
  • Loading branch information
celprov committed Apr 24, 2024
1 parent f133a87 commit c9bf3ed
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mriqc_learn/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def load_data(
Parameters
----------
path : :obj:`os.pathlike`
Whether to indicate a custom path were data are written in a TSV file.
path : :obj:`os.pathlike` or :obj:`pd.DataFrame`
Either a custom path where data are written in a TSV file, or a pandas DataFrame containing the data directly.
split_strategy : ``None`` or :obj:`str`
How the data must be split into train and test subsets.
Possible values are: ``"random"`` (default), ``"site"``, or ``None``/``"none"``.
Expand All @@ -88,10 +88,14 @@ def load_data(
if site is not None:
split_strategy = "site"

if path is None:
path = Path(pkgrf("mriqc_learn.datasets", "abide.tsv"))
if isinstance(path, pd.DataFrame):
dataframe = path
else:
if path is None:
path = Path(pkgrf("mriqc_learn.datasets", "abide.tsv"))

dataframe = pd.read_csv(path, index_col=None, delimiter=r"\s+")

dataframe = pd.read_csv(path, index_col=None, delimiter=r"\s+")
xy_index = dataframe.columns.tolist().index(first_iqm)

if split_strategy is None or split_strategy.lower() == "none":
Expand Down

0 comments on commit c9bf3ed

Please sign in to comment.