Skip to content
Open
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
11 changes: 9 additions & 2 deletions Modules/IO/GDCM/include/itkGDCMSeriesFileNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ namespace itk
* orientation), an exception is thrown by default; see
* FailOnAmbiguousOrdering. When FailOnAmbiguousOrdering is false, the
* ordering falls back to 'Instance Number' when unique, else to
* lexicographic filename order.
* lexicographic filename order (and in either case, DidUseAmbiguousOrdering
* is set to true).
*
* If multiple volumes are being grouped as a single series for your
* DICOM objects, you may want to try calling SetUseSeriesDetails(true)
Expand Down Expand Up @@ -172,7 +173,7 @@ class ITKIOGDCM_EXPORT GDCMSeriesFileNames : public ProcessObject
void
AddSeriesRestriction(const std::string & tag);

/** Throw an exception when a series cannot be ordered geometrically by
/** When true, throw an exception when a series cannot be ordered geometrically by
* gdcm::IPPSorter (duplicate ImagePositionPatient, inconsistent
* orientation). When false, fall back to the legacy SerieHelper
* heuristics: Instance Number when unique, else lexicographic filename
Expand All @@ -184,6 +185,11 @@ class ITKIOGDCM_EXPORT GDCMSeriesFileNames : public ProcessObject
itkBooleanMacro(FailOnAmbiguousOrdering);
/** @ITKEndGrouping */

/** If ambiguous ordering is encountered, this is set to true. */
/** @ITKStartGrouping */
itkGetConstMacro(DidUseAmbiguousOrdering, bool);
Comment on lines +189 to +190

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Diagnostic result is publicly mutable

itkSetMacro(DidUseAmbiguousOrdering, bool) and itkBooleanMacro(DidUseAmbiguousOrdering) publish setters that allow callers to clear a real fallback result or fabricate one. Because the generated setter calls Modified(), changing this reporting-only value also invalidates the MTime-based series-map cache. Expose only a getter and keep updates to this result internal to the ordering implementation.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

/** @ITKEndGrouping */

/** No effect with the gdcm::Scanner backend (retained for source
* compatibility). Series enumeration reads only the grouping and
* ordering tags, so sequences are never parsed during the scan.
Expand Down Expand Up @@ -256,6 +262,7 @@ class ITKIOGDCM_EXPORT GDCMSeriesFileNames : public ProcessObject

bool m_UseSeriesDetails = false;
bool m_FailOnAmbiguousOrdering = true;
bool m_DidUseAmbiguousOrdering = false;
bool m_Recursive = false;
bool m_LoadSequences = false;
bool m_LoadPrivateTags = false;
Expand Down
9 changes: 8 additions & 1 deletion Modules/IO/GDCM/src/itkGDCMSeriesFileNames.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ GDCMSeriesFileNames::OrderSeries(SeriesEntry & entry)
// acquisitions (see issue #6468).
gdcm::IPPSorter sorter;
sorter.SetComputeZSpacing(false);
if (sorter.Sort(entry.Files))
bool wasSortingAchieved = sorter.Sort(entry.Files);

// Set a public flag so that callers know this fallback occurred, and can show a warning.
m_DidUseAmbiguousOrdering = !wasSortingAchieved;

if (wasSortingAchieved)
{
entry.Files = sorter.GetFilenames();
entry.Ordered = true;
Expand All @@ -230,6 +235,7 @@ GDCMSeriesFileNames::OrderSeries(SeriesEntry & entry)
"orientation, see issue #6468). Set FailOnAmbiguousOrdering to false to accept the legacy "
"non-standard ordering heuristics.");
}

// Legacy SerieHelper heuristics (Instance Number, then lexicographic),
// kept only for determinism and backward compatibility: an untrustworthy,
// non-standard hack whose output should not be trusted.
Expand Down Expand Up @@ -412,6 +418,7 @@ GDCMSeriesFileNames::PrintSelf(std::ostream & os, Indent indent) const

itkPrintSelfBooleanMacro(UseSeriesDetails);
itkPrintSelfBooleanMacro(FailOnAmbiguousOrdering);
itkPrintSelfBooleanMacro(DidUseAmbiguousOrdering);
itkPrintSelfBooleanMacro(Recursive);
itkPrintSelfBooleanMacro(LoadSequences);
itkPrintSelfBooleanMacro(LoadPrivateTags);
Expand Down
Loading