Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] ADNI utils load_clinical_csv should avoid hidden files #1343

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading