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

FATAL ERROR: Writing of the SEG dataset failed #250

Closed
alexisdurieux opened this issue May 16, 2017 · 16 comments
Closed

FATAL ERROR: Writing of the SEG dataset failed #250

alexisdurieux opened this issue May 16, 2017 · 16 comments

Comments

@alexisdurieux
Copy link

Hi, I'm trying to use the library to generate a DICOM Seg with itkimage2segimage. For the context I'm trying to segment only one slice of a set of dicoms, so the nrrd file is nrrd_mat is full of zeros except for the one slice we are trying to segment However, whenever we try a fatal error occurs. Here is the full error:

./itkimage2segimage --inputDICOMDirectory /home/utilisateurs/adurieux/qualite/ressources/patient1 --inputMetadata ./patient.json --inputImageList nrrd_mat.nrrd --outputDICOM ./segmentation.dcm
dcmqi repository URL: git@github.com:QIICR/dcmqi.git revision: 1127a37 tag: latest-15-g1127a37
Searching recursively /home/utilisateurs/adurieux/qualite/ressources/patient1 for DICOM files
Input image size: [512, 512, 452]
W: PatientAge (0010,1010) violates VR definition in PatientStudyModule
Directions: 1 0 0
0 1 0
0 0 1

Processing input label Image (0x178ed40)
  RTTI typeinfo:   itk::Image<short, 3u>
  Reference Count: 3
  Modified Time: 176
  Debug: Off
  Object Name:
  Observers:
    none
  Source: (none)
  Source output name: (none)
  Release Data: Off
  Data Released: False
  Global Release Data: Off
  PipelineMTime: 48
  UpdateMTime: 175
  RealTimeStamp: 0 seconds
  LargestPossibleRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [512, 512, 452]
  BufferedRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [512, 512, 452]
  RequestedRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [512, 512, 452]
  Spacing: [1, 1, 1]
  Origin: [0, 0, 0]
  Direction: 
1 0 0
0 1 0
0 0 1

 IndexToPointMatrix: 
1 0 0
0 1 0
0 0 1

 PointToIndexMatrix: 
1 0 0
0 1 0
0 0 1

 Inverse Direction: 
1 0 0
0 1 0
0 0 1

 PixelContainer:
    ImportImageContainer (0x178efd0)
      RTTI typeinfo:   itk::ImportImageContainer<unsigned long, short>
      Reference Count: 1
      Modified Time: 172
      Debug: Off
      Object Name:
      Observers:
        none
      Pointer: 0x7f7194355010
      Container manages memory: true
      Size: 118489088
      Capacity: 118489088

Found 5 label(s)
Skipping label 0
Processing label 1
Total non-empty slices that will be encoded in SEG for label 1 is 452
 (inclusive from 0 to 452)
Processing label 2
Total non-empty slices that will be encoded in SEG for label 2 is 452
 (inclusive from 0 to 452)
Processing label 3
Total non-empty slices that will be encoded in SEG for label 3 is 452
 (inclusive from 0 to 452)
Processing label 4
Total non-empty slices that will be encoded in SEG for label 4 is 452
 (inclusive from 0 to 452)
W: PatientAge (0010,1010) violates VR definition in PatientStudyModule
FATAL ERROR: Writing of the SEG dataset failed! Please report the problem to the developers, ideally accompanied by a de-identified dataset allowing to reproduce the problem!

Do you have any ideas on what we are doing wrong or if it's a bug related issue ?

Alexis

@fedorov
Copy link
Member

fedorov commented May 16, 2017

@alexisdurieux thanks for your report!

I believe the reason for this is the same as described in #232. The input image series that you are segmenting seems to contain attributes that violate the standard. It could be that the problems were introduced during the de-identification process. There is currently no way to force dcmqi to write the output.

To confirm that this is indeed the source of the problem, you can modify your input DICOM series to have a valid value for PatientAge, and try running the converter again.

If you are on a Mac or Linux, and have DCMTK installed, you can do it using dcmodify command as shown below (note this command will overwrite your DICOM datasets - you might want to test it with a copy of the dataset; also note this command assumes the directory contains a flat list of DICOM files):

$ for f in `ls`;do dcmodify -nb -m PatientAge=10 ${f};done

If you don't have DCMTK installed, you can use the docker image we provide here https://hub.docker.com/r/qiicr/docker-dcmtk-cli/:

$ docker pull qiicr/docker-dcmtk-cli
$ for f in `ls`;do docker run -v `pwd`:/tmp/work qiicr/docker-dcmtk-cli dcmodify -nb -m PatientAge=10 /tmp/work/${f};done

(at the moment, the command above will not work, since I realized there is a problem with the way we build the docker image, I pushed a fix, and will update this issue when I confirm it is working)

Please let us know if the instructions above fix the problem for you, or it is something else.

@fedorov
Copy link
Member

fedorov commented May 16, 2017

@alexisdurieux I confirm the updated docker image is fixed, and the following command should work (I added echo, since it is quite slow):

$ docker pull qiicr/docker-dcmtk-cli
$ for f in `ls`;do echo "Processing ${f}"; docker run -v `pwd`:/tmp/work qiicr/docker-dcmtk-cli dcmodify -nb -m PatientAge=10 /tmp/work/${f};done

@alexisdurieux
Copy link
Author

Hi @fedorov thank you for your quick answer ! Are there any way to fix it without using the docker image and instead the binary ? Thanks a lot, i tried the command: $ for f in ls;do dcmodify -nb -m PatientAge=10 ${f};done with success and still have the same error while trying to generate the segmentation afterwards though.

@fedorov
Copy link
Member

fedorov commented May 16, 2017

You still have the same error after modifying PatientAge? Can you include the last few lines of the console output?

@alexisdurieux
Copy link
Author

It seems that the PatientAge wasn't modified with success. My bad, I try to use your docker image but there is an error while processing the images (Docker daemon socker). I try to figure this out and come back to you

@fedorov
Copy link
Member

fedorov commented May 16, 2017

Hmm, you should not need to use the docker to modify, it should work with the command line tool. Were there any errors?

Were you running the command I provided inside a directory that has the DICOM files you are passing as input to dcmqi?

@alexisdurieux
Copy link
Author

Alright so I managed to kill the warning by replacing the patient age with a correct VR value for instance 023Y with your command line. However I still have one error:

Condition failed: Is a directory in ../../apps/seg/itkimage2segimage.cxx:70
terminate called after throwing an instance of 'int'
Erreur : lors de l'appel de itkimage2segimage

Any idea where it comes from ?

@fedorov
Copy link
Member

fedorov commented May 16, 2017

Alright so I managed to kill the warning by replacing the patient age with a correct VR value for instance 023Y with your command line.

Ah, of course! Very sorry for giving you imprecise and misleading instructions. Glad you figured it out!

Condition failed: Is a directory in ../../apps/seg/itkimage2segimage.cxx:70
Any idea where it comes from ?

Please check that the the argument you pass to the --outputDICOM flag is a file name, not a directory! The output of this converter is a new file that it will create.

@alexisdurieux
Copy link
Author

Thank you so much for your help ! It was indeed the problem. The segmentation is now saved successfully !

@fedorov
Copy link
Member

fedorov commented May 17, 2017

@alexisdurieux great, thank you for confirming! Sorry for the trouble.

I am closing this issue, since its essence is covered by #232 and #225.

@fedorov fedorov closed this as completed May 17, 2017
@fedorov
Copy link
Member

fedorov commented May 18, 2017

@michaelonken it is somewhat misleading that the data issue is reported as a warning (see #250 (comment)), but in fact leads to the failure while writing the dataset. Is this expected?

W: PatientAge (0010,1010) violates VR definition in PatientStudyModule

@michaelonken
Copy link
Member

Expected but not desired I guess. The reason is that the same check routine is used when reading and writing. I think the desired output is a warning when reading, and an error when writing.

The natural way to resolve this put an extra parameter to the called check..() method which tells the routine which logger to use. I have to check whether its easily possible (or requires adding parameter to many calling methods). What do you think, worth spending 1-2 hours on it?

@fedorov
Copy link
Member

fedorov commented May 19, 2017

Michael, yes - I think it is a good idea to see if it is an easy fix.

@michaelonken
Copy link
Member

I fixed this today in DCMTK testing branch. The commit 71496d will be visible in the next days in the public upstream DCMTK master. If you want to try this before it is published, you can find a copy of the current OFFIS testing branch in my private github copy: https://github.com/michaelonken/dcmtk (branch offis_testing)

@fedorov
Copy link
Member

fedorov commented May 19, 2017

Great, thank you Michael! I confirm this works as expected - error before write failure when the referenced image data is invalid. The issue related to the fractional segmentation is also gone. Once it is published, we should upgrade DCMTK for dcmqi and Slicer!

@fedorov
Copy link
Member

fedorov commented Jan 24, 2022

also related to #212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants