Skip to content

Commit

Permalink
fix broken exception
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen committed Jul 24, 2024
1 parent 6da3b92 commit 30f0be7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions clinica/iotools/utils/data_handling/_merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _compute_session_rows_for_subject_with_session_files(
This function will try to incorporate data from the sessions and scans
if available.
"""
from ..pipeline_handling import DatasetError
from clinica.utils.exceptions import ClinicaDatasetError

rows = []
sub_path = bids_dir / subject
Expand All @@ -228,7 +228,9 @@ def _compute_session_rows_for_subject_with_session_files(
row_session_df = sessions_df[sessions_df.session_id == session]
row_session_df.reset_index(inplace=True, drop=True)
if len(row_session_df) == 0:
raise DatasetError(sessions_df.loc[0, "session_id"] + " / " + session)
raise ClinicaDatasetError(
f"The following sessions are not properly formatted : {sessions_df.loc[0, 'session_id']} / {session}"
)
scan_path = bids_dir / subject / session / f"{subject}_{session}_scans.tsv"
row_scans_df = _get_row_scan_df(scan_path, ignore_scan_files)
row_df = pd.concat([row_session_df, row_scans_df], axis=1)
Expand Down
16 changes: 10 additions & 6 deletions clinica/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@ class ClinicaEnvironmentVariableError(ClinicaException):
"""Something is wrong with an environment variable managed by Clinica."""


class ClinicaBIDSError(ClinicaException):
"""Base class for BIDS errors."""
class ClinicaDatasetError(ClinicaException):
"""Base class for errors related to Datasets."""


class ClinicaCAPSError(ClinicaException):
"""Base class for CAPS errors."""
class ClinicaBIDSError(ClinicaDatasetError):
"""Base class for BIDS dataset errors."""


class ClinicaCAPSError(ClinicaDatasetError):
"""Base class for CAPS dataset errors."""


class ClinicaParserError(ClinicaException):
"""Base class for parser errors."""


class ClinicaXMLParserError(ClinicaException):
"""Base class for parser errors."""
class ClinicaXMLParserError(ClinicaParserError):
"""Base class for XML parser errors."""


class ClinicaInconsistentDatasetError(ClinicaException):
Expand Down

0 comments on commit 30f0be7

Please sign in to comment.