AssertionError: Conflicting study identifiers found” in heudiconv
Summary
Platform details:
Choose one:
- [ ] Local environment
- [ ] Container
- Heudiconv version:
My sample folders are organized in this way. I use Philips fMRI data from ADNI, and each subject has different imaging date numbers. In other words, multiple subjects with multiple sessions without any rule. .dcm files are located in ‘anat’ and ‘func’ folder respectively.
Myproject
- Dicom2
- 130S4883
- 20120103 - anat - func
- 20130506 - anat - func
- 136S4517
- 20140506
- anat
- func
- 20151104
- anat
- func
- 20161107
- anat
- func
- 20140506
- 130S4883
And I used heudiconv on Linux terminal. The code I used is attached below.
for subject in $(ls -1 /home/rrt/MyProject/Dicom2/); do
for session in $(ls -1 /home/rrt/MyProject/Dicom2/${subject/}); do
sudo docker run --rm -it
-v /home/rrt/MyProject:/base
nipy/heudiconv:latest
-d /base/Dicom2/{subject}/{session}/* /*.dcm
-o /base/Nifti2_sess2/
-f /base/Nifti2_sess2/code/convertall.py
-s ${subject}
-ss ${session}
-c dcm2niix -b
–overwrite;
done;
done
Error such as “AssertionError: Conflicting study identifiers found [2.16.124.113543.6006.99.06413494192697466191, 2.16.124.113543.6006.99.04058827386078038047].” occured. What should I do?
Below is the convertall.py file.
def infotodict(seqinfo):
# Section 1: These key definitions should be revised by the user scanner.
data = create_key('run-{item:03d}')
t1w = create_key('sub-{subject}/{session}/anat/sub-{subject}_{session}_T1w')
func_rest = create_key('sub-{subject}/{session}/func/sub-{subject}_{session}_task-rest_bold')
# Section 1b: This data dictionary (below) should be revised by the user.
info = {data: [], t1w: [], func_rest: []}
last_run = len(seqinfo)
# Section 2: These criteria should be revised by user.
for idx, s in enumerate(seqinfo):
if ('MPRAGE' in s.protocol_name) and (s.dim3 == 170):
info[t1w].append(s.series_id)
if ('Resting' in s.protocol_name):
info[func_rest].append(s.series_id)
return info
@JiyoungByun this means heudiconv was given DICOMs from 2 different studies - by default this will throw an error to prevent erroneous conversions.
Reviving this issue once again because in reading through the various threads I'm not finding a clearly articulated solution, other than grouping by accession number, which hasn't worked for me (or many others, it seems).
Wondering if there is anything for me to do other than renaming the DICOM files with the second study identifier (which would be the least appealing option short of doing a manual conversion to BIDS).
Thanks in advance for any help or suggestions.
@mgxd Out of curiosity, what do you mean exactly by "erroneous conversions"? What implications does ignoring study ID (as dcm2niix seems to do) have for analysis?
This issue seems very old but for anyone coming here via Google or whatnot, pydicom makes it very easy to read study IDs, which you can use to script reorganizing files. For example
import pydicom
import glob
import os
from pathlib import Path
alldcm = glob.glob('/path/to/dicoms/*/*')
for i in range(0, len(alldcm)):
ds = pydicom.dcmread(alldcm[i])
fn = os.path.basename(alldcm[i])
path = Path('/path/to/symlinks/' + ds.StudyInstanceUID)
path.mkdir(parents=True, exist_ok=True)
print(alldcm[i], ds.StudyInstanceUID)
os.symlink(alldcm[i], '/path/to/symlinks/' + ds.StudyInstanceUID + '/' + fn)
Is there a solution to this? I have a single study that just happens to have varying study identifiers.
--grouping all: https://github.com/nipy/heudiconv/pull/359