Skip to content

Commit

Permalink
[FIX] ADNI utils load_clinical_csv should avoid hidden files (arami…
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceJoubert authored and NicolasGensollen committed Oct 24, 2024
1 parent 999cd3d commit 539cc4e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clinica/iotools/converters/adni_to_bids/adni_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ def load_clinical_csv(clinical_dir: Path, filename: str) -> pd.DataFrame:

pattern = filename + r"(_\d{1,2}[A-Za-z]{3}\d{4})?.csv"
files_matching_pattern = [
f for f in clinical_dir.rglob("*.csv") if re.search(pattern, f.name)
f for f in clinical_dir.rglob("[!.]*.csv") if re.search(pattern, f.name)
]
if len(files_matching_pattern) != 1:
raise IOError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def test_compute_session_id(csv_filename, visit_code_column_name):


@pytest.fixture
def input_df():
def input_df() -> pd.DataFrame:
return pd.DataFrame(
{
"foo": ["foo1", "foo2", "foo3"],
Expand All @@ -255,6 +255,7 @@ def test_load_clinical_csv(tmp_path, input_df, csv_name, csv_to_look_for):
from clinica.iotools.converters.adni_to_bids.adni_utils import load_clinical_csv

input_df.to_csv(tmp_path / csv_name, index=False)
pd.DataFrame().to_csv(tmp_path / f".{csv_name}")
assert_frame_equal(load_clinical_csv(tmp_path, csv_to_look_for), input_df)


Expand All @@ -278,8 +279,6 @@ def test_load_clinical_csv_error(


def test_load_clinical_csv_value_error(tmp_path):
import re

from clinica.iotools.converters.adni_to_bids.adni_utils import load_clinical_csv

with open(tmp_path / "adnimerge.csv", "w") as fp:
Expand Down

0 comments on commit 539cc4e

Please sign in to comment.