<div dir="ltr">Hi Eddy,<div><br></div><div>The SOPInstanceUID must be different for each image (and the other two UIDs shouldn't be the same as the SeriesInstanceUID, either).</div><div><br></div><div>What version of vtk-dicom are you using, and what operating system?  I can check on my end to make sure that the random numbers for the UUIDs are being properly generated.  I use CryptGenRandom() on Windows and /dev/urandom on UNIX/Linux.</div><div><br></div><div> - David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 26, 2017 at 9:05 AM, Eddy Cappeau <span dir="ltr"><<a href="mailto:edcpwk@gmail.com" target="_blank">edcpwk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi David, <br><br></div>When I load the DICOM directory, Slicer tells me that there's only one serie.<br></div>Each image have the same SeriesInstanceUID.<br></div><br>I don't know if it's normal but the SeriesInstanceUID is also used for the SOPInstanceUID, the StudyInstanceUID and the FrameOfReferenceUID.<br><br></div><div>I've made a screenshot of the Slicer metadata browser here : <br></div><div><br><a href="https://framapic.org/t3tTt1RHhlWP/XhHP9dQ2Nz8s.png" target="_blank">https://framapic.org/<wbr>t3tTt1RHhlWP/XhHP9dQ2Nz8s.png</a><span class="HOEnZb"><font color="#888888"><br><br><br></font></span></div><span class="HOEnZb"><font color="#888888">Eddy<br><div><div><br></div></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-01-26 15:43 GMT+01:00 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Eddy,<div><br></div><div>In Slicer's DICOM browser, does it show all of the images as belonging to the same series?  I'm wondering if, perhaps, each image has a different SeriesInstanceUID.  That would definitely cause problems with loading into a "dicom aware" program like Slicer, but ParaView probably wouldn't care.</div><span class="m_3503947074277776307HOEnZb"><font color="#888888"><div><br></div><div> - David</div></font></span></div><div class="m_3503947074277776307HOEnZb"><div class="m_3503947074277776307h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 26, 2017 at 7:30 AM, Eddy Cappeau <span dir="ltr"><<a href="mailto:edcpwk@gmail.com" target="_blank">edcpwk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi Andras,<br><br></div>I didn't manage to load un single image before.<br></div><div><br></div><div>Thank you for the tip.<span class="m_3503947074277776307m_1562638101421130448HOEnZb"><font color="#888888"><br></font></span></div><span class="m_3503947074277776307m_1562638101421130448HOEnZb"><font color="#888888"><div><br></div>Eddy<br></font></span></div><div class="m_3503947074277776307m_1562638101421130448HOEnZb"><div class="m_3503947074277776307m_1562638101421130448h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-01-26 15:28 GMT+01:00 Eddy Cappeau <span dir="ltr"><<a href="mailto:edcpwk@gmail.com" target="_blank">edcpwk@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hello David, <br><br>I used the vtkDICOMMRGenerator filter, unsigned short instead of unsigned char and add this line : <br><br>     meta->SetAttributeValue(DC::Sp<wbr>acingBetweenSlices, "1"); <br><br>The BitsAllocated has now a value of 16 but I've got the same result.<br><br></div>Thanks to the tips given by Andras, I've opened each slice individually and they seems correct.  <br><br></div></div><div><div>There's definitly something wrong in my files, but I don't see why.<br><br></div><div>Thanks.<span class="m_3503947074277776307m_1562638101421130448m_5976851390538144563HOEnZb"><font color="#888888"><br></font></span></div><span class="m_3503947074277776307m_1562638101421130448m_5976851390538144563HOEnZb"><font color="#888888"><div><br>Eddy<br></div></font></span></div></div><div class="m_3503947074277776307m_1562638101421130448m_5976851390538144563HOEnZb"><div class="m_3503947074277776307m_1562638101421130448m_5976851390538144563h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-01-25 14:35 GMT+01:00 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Eddy,<div><br></div><div>The code is using a vtkDICOMCTGenerator to write an MR image, which is definitely wrong.  Use the vtkDICOMMRGenerator, and make sure the meta data matches the IOD: <a href="http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.8.3.html" target="_blank">http://dicom.nema.org/med<wbr>ical/dicom/current/output/chtm<wbr>l/part03/sect_C.8.3.html</a></div><div><br></div><div>The standard says that BitsAllocated must be 16 for MR images, therefore an 8-bit MR image is non-standard and DICOM software may to refuse to display it.  You should convert your data to 16-bit (In fact, it seems fishy that you are working with unsigned char, since if you are writing a reformat of an MR image, then wasn't the original MR image a 16-bit image?)</div><div><br></div><div>I can't answer about why Slicer is only showing one slice, as I don't currently have Slicer installed.</div><span class="m_3503947074277776307m_1562638101421130448m_5976851390538144563m_6602017693135991195HOEnZb"><font color="#888888"><div><br></div><div> - David  </div><div><br></div><div><br></div></font></span></div><div class="m_3503947074277776307m_1562638101421130448m_5976851390538144563m_6602017693135991195HOEnZb"><div class="m_3503947074277776307m_1562638101421130448m_5976851390538144563m_6602017693135991195h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 25, 2017 at 1:57 AM, Eddy Cappeau <span dir="ltr"><<a href="mailto:edcpwk@gmail.com" target="_blank">edcpwk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi David,<br><br>Here's the code below. This is almost the example of the api doc :<br><br>    auto generator = vtkSmartPointer <vtkDICOMCTGenerator>::New();<br>    vtkSmartPointer <vtkDICOMMetaData> meta = vtkSmartPointer <vtkDICOMMetaData>::New();<br><br>    meta->SetAttributeValue(DC::Pa<wbr>tientName, "Test");<br>    meta->SetAttributeValue(DC::Pa<wbr>tientID, "0000001");<br>    meta->SetAttributeValue(DC::Sc<wbr>anOptions, "");<br>    meta->SetAttributeValue(DC::Sc<wbr>anningSequence, "GR");<br>    meta->SetAttributeValue(DC::Se<wbr>quenceVariant, "SP");<br>    meta->SetAttributeValue(DC::Sc<wbr>anOptions, "");<br>    meta->SetAttributeValue(DC::MR<wbr>AcquisitionType, "2D");<br><br>    vtkSmartPointer <vtkDICOMWriter> dicom_writer =<br>        vtkSmartPointer <vtkDICOMWriter>::New();<br>    dicom_writer->SetInputData(img<wbr>);<br>    dicom_writer->SetMetaData(meta<wbr>);<br>    dicom_writer->SetGenerator(gen<wbr>erator);<br>    dicom_writer->SetSeriesDescrip<wbr>tion("Sagittal Multi-planar Reformat");<br><br>    // Set the output filename format as a printf-style string.<br>    dicom_writer->SetFilePattern("<wbr>%s/IM-0001-%04.4d.dcm");<br>    // Set the directory to write the files into.<br>    dicom_writer->SetFilePrefix(pa<wbr>th.toStdString().c_str());<br>    // Write the file.<br>    dicom_writer->Write();<br><br></div>Sorry, the use of an unsigned short type was a carreless mistake. The result is better with unsigned char,<br></div>but I still see just one image of the serie on 3D Slicer. Is there something missing to have a complete serie ? <br><br></div><div>I didn't know the vtkImageImport and I'll give it a try.<br></div><div><br><div><div><div><div><div><div>Thanks,<br><br></div><div>Eddy<span class="m_3503947074277776307m_1562638101421130448m_5976851390538144563m_6602017693135991195m_-2976504475948437423m_3219583261859247826gmail-sy1"></span></div><div><br></div></div></div></div></div></div></div></div><div class="m_3503947074277776307m_1562638101421130448m_5976851390538144563m_6602017693135991195m_-2976504475948437423HOEnZb"><div class="m_3503947074277776307m_1562638101421130448m_5976851390538144563m_6602017693135991195m_-2976504475948437423h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-01-24 15:41 GMT+01:00 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Eddy,</div><div><br></div><div>Can you provide the code that you used to write the image with vtkDICOMWriter?  Here is an example:</div><div><a href="http://dgobbi.github.io/vtk-dicom/doc/api/image_writer.html" target="_blank">http://dgobbi.github.io/vtk-di<wbr>com/doc/api/image_writer.html</a><br></div><div><br></div><div>Creating an image with a loop that calls GetScalarPointer() for every pixel is not very efficient, and casting to a "char *" when the data is "unsigned short" is wrong: you are setting only 8 bits of each 16-bit pixel, while leaving the other 8 bits uninitialized.  The vtkImageImport filter is a better way of generating image data:</div><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/ImageImport" target="_blank">http://www.vtk.org/Wiki/VTK/Ex<wbr>amples/Cxx/Images/ImageImport</a><span class="m_3503947074277776307m_1562638101421130448m_5976851390538144563m_6602017693135991195m_-2976504475948437423m_3219583261859247826HOEnZb"><font color="#888888"><div><br></div><div> - David</div></font></span><div><div class="m_3503947074277776307m_1562638101421130448m_5976851390538144563m_6602017693135991195m_-2976504475948437423m_3219583261859247826h5"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 24, 2017 at 2:51 AM, Eddy Cappeau <span dir="ltr"><<a href="mailto:edcpwk@gmail.com" target="_blank">edcpwk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>I'd like to use the vtkDICOMWriter class to convert a vtkImage to a set of DICOM images.<br></div><div><br>I've compile VTK with the vtkDICOM module enabled and followed the example from the pdf found on the github repository (<a href="http://dgobbi.github.io/vtk-dicom/doc/vtk-dicom.pdf" target="_blank">http://dgobbi.github.io/vtk-d<wbr>icom/doc/vtk-dicom.pdf</a>).<br><div><br></div><br>The image data is created like this :<br><br>    auto  img = vtkSmartPointer < vtkImageData >::New();<br>    img->SetOrigin(0, 0, 0);<br>    img->SetDimensions(1024, 1024, numlayer);<br>    img->SetSpacing(1, 1, 1);<br>    img->AllocateScalars(VTK_UNSIG<wbr>NED_SHORT, 1);<br><br></div>and the data filled like this : <br><br>           for (int n = 0; x < numlayer; n++) {<br>                for (int x = 0; x < 1024; x++) {<br>                    for (int y = 0; y < 1024; y++) {<br>                        char* pixel = static_cast<char*>(img->GetSca<wbr>larPointer(x, y, n));<br>                        pixel[0] = values[x][y];<br>                    }<br></div><div><br></div>I can load the converted result with paraview without problems.<br>But with 3D Slicer, I can just load the first file of the serie and it display a blank image.<br><br></div>What do I have to do to be able to load the images with both application ?<br></div><div><br>Thanks, <br><br></div>Eddy</div></blockquote></div><br></div></div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>