Is it possible in HeuDiConv to group DICOMs by directory name

Hello,

Is it possible in HeuDiConv to group DICOMs by directory name?

I am submitting multiple DICOM directories to HeuDiConv using --files $FOLDER_LIST, where each folder points to a DICOM series (e.g., /my_path/Series_003_MEPI_AF3_35iso_3xTE_TR2000_B350_VSTM).

From what I understand, HeuDiConv looks inside all DICOM files (independent of which folder they came from), and creates a series_id by combining SeriesNumber and ProtocolName (e.g., 3-MEPI_AF3_35iso_3xTE_TR2000_B350_VSTM). This series_id is then used to organize the seqinfo list in the heuristic.

However, in my session, the scanner was stopped and restarted before the third run. As a result, SeriesNumber started again from 1, and StudyID changed to 2.

  • When using the default grouping (by StudyID), I get an error:
    AssertionError: Existing study session StudySessionInfo(...) already in analyzed sessions
  • When using --grouping all, the grouping becomes wrong: Series from before and after the interruption are merged incorrectly (please see the attached image illustrating the mismatch).
  • I also attach the dicominfo table generated by HeuDiConv.

It seems that HeuDiConv cannot currently differentiate the series correctly because SeriesNumber overlaps.

My question:

  • Is there a way to force HeuDiConv to group DICOMs based on their input directory instead of DICOM header fields?
  • Or at least to ensure that DICOMs from different input folders are treated as separate series, even if their SeriesNumber overlaps?

I would appreciate any advice on how to solve this!

The wrong grouping and conversion:

dicominfo.tsv:

quick one: do you have a unique (same) accession id assigned to them? then we also have it as an option to try

  -g, --grouping {studyUID,accession_number,all,custom}
                        How to group dicoms (default: by studyUID).

and you can see that thereis also custom as an option. See Heuristics File — heudiconv 1.3.3 documentation so there you should be able to come up with groupping based on filenames, just add such grouping function to your heuristic

Unfortunately, no. accession_number is empty in the dicom metadata :frowning:

I was trying to use ‘custom’ with various options. Nothing worked, it always returned the AssertionError: Existing study session StudySessionInfo(...) already in analyzed sessions.

For example, I tried,

-g custom

and in the heuristic: grouping = 'StudyTime'

It returned the ‘AssertionError’.

And I don’t know how to correctly use the grouping function based on this template from the documentation.

def grouping(files, dcmfilter, seqinfo):
    seqinfos = collections.OrderedDict()
    ...
    return seqinfos

I tried some things, but nothing worked.

yes, we need a better example there… ping me if you don’t hear back in few days. meanwhile – so both StudyTime and folder name would work for you?

Yes, either StudyTime or folder name. Thanks.