<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">ITK's naming convention is opposite to DICOM's. DICOM's LPS is called RAI in ITK. So there might not be any problem regarding that.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 21, 2016 at 8:59 AM, Paulo Guilherme Freire <span dir="ltr"><<a href="mailto:pauloguilhermefreire@gmail.com" target="_blank">pauloguilhermefreire@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">Hello, Timothee. Thank you for your suggestions. <div><br></div><div>I opened the new file on ITK-Snap and saw that the LPS orientation was not successfully streamed to it. The orientation ITK-Snap is showing the image is in is RAI. I tried changing the LPS orientation to RAS in the .nhdr file (since according to <a href="http://teem.sourceforge.net/nrrd/format.html#space" target="_blank">http://teem.sourceforge.net/nrrd/format.html#space</a>, there is no support to RAI). By doing so, I wasn't even able to save the image to a new file.</div><div><br></div><div>Regarding the filter that is causing this problem, I believe that the reader is to blame. If I open the raw image on ITK-Snap and manually input the .nhdr information, the image is loaded (almost) succesfully. I say almost because the orientation still remains RAI instead of LPS. </div><div><br></div><div>Best,</div><div>Paulo</div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Sat, May 21, 2016 at 8:47 AM Timothee Evain <<a href="mailto:tevain@telecom-paristech.fr" target="_blank">tevain@telecom-paristech.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Paulo,<br>
<br>
Some suggestions:<br>
-Is the LPS orientation of your data streamed successfully to your new file ?<br>
-Which filter is in cause ? the reader or the writer ? Are you able to visualize your data after loading it but before writing it (with VTK for example) ?<br>
<br>
Tim<br>
<br>
<br>
<br>
----- Mail original -----<br>
De: "Paulo Guilherme Freire" <<a href="mailto:pauloguilhermefreire@gmail.com" target="_blank">pauloguilhermefreire@gmail.com</a>><br>
À: "Dženan Zukić" <<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>><br>
Cc: <a href="mailto:community@itk.org" target="_blank">community@itk.org</a><br>
Envoyé: Vendredi 20 Mai 2016 22:54:44<br>
Objet: Re: [ITK] Read raw image and save as nii<br>
<br>
Hello, Dženan. Thank you for your suggestion. I just tried using endian: big, but still no success.<br>
<br>
Best,<br>
Paulo<br>
<br>
On Fri, May 20, 2016 at 5:46 PM Dženan Zukić < <a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a> > wrote:<br>
<br>
<br>
<br>
Can you try endian: big?<br>
<br>
On Fri, May 20, 2016 at 2:18 PM, Paulo Guilherme Freire < <a href="mailto:pauloguilhermefreire@gmail.com" target="_blank">pauloguilhermefreire@gmail.com</a> > wrote:<br>
<br>
<br>
<br>
Hi, Matt.<br>
<br>
Thank you for your answer! I tried different kinds of image pixel type (short, unsigned short, int, unsigned char, double) but to no avail. I really don't know what's wrong.<br>
<br>
An example of a .nhdr file I'm using is the following:<br>
<br>
NRRD0004<br>
# Complete NRRD file format specification at:<br>
# <a href="http://teem.sourceforge.net/nrrd/format.html" rel="noreferrer" target="_blank">http://teem.sourceforge.net/nrrd/format.html</a><br>
type: short<br>
dimension: 3<br>
space: left-posterior-superior<br>
sizes: 512 512 512<br>
space directions: (0.5,0,0) (0,0.5,0) (0,0,0.5)<br>
kinds: domain domain domain<br>
endian: little<br>
encoding: raw<br>
space origin: (0,0,0)<br>
data file: CHB_train_Case01_FLAIR.raw<br>
<br>
Best,<br>
Paulo<br>
<br>
Matt McCormick < <a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a> > schrieb am Fr., 20. Mai 2016, 15:03:<br>
<br>
<br>
Hi Paulo,<br>
<br>
Your code looks good. Is the image pixel type correct for the input data?<br>
<br>
HTH,<br>
Matt<br>
<br>
On Fri, May 20, 2016 at 12:36 PM, Paulo Guilherme Freire<br>
< <a href="mailto:pauloguilhermefreire@gmail.com" target="_blank">pauloguilhermefreire@gmail.com</a> > wrote:<br>
> Hello, everyone.<br>
><br>
> I am trying to do something quite simple: I have a raw image (and its<br>
> corresponding .nhdr file) and I want to read it and save it in .nii format.<br>
> The image type, according to the .nhdr file, is short. Below is the code I'm<br>
> using.<br>
><br>
> My question is: what am I missing here? After I save the image to file and<br>
> open it, I don't get the expected result; rather, I get an image that<br>
> reminds a TV static.<br>
><br>
> Could you please help me?<br>
><br>
> Thanks in advance!<br>
><br>
> Best,<br>
> Paulo<br>
><br>
> #include <iostream><br>
> #include <itkImage.h><br>
> #include <itkImageFileWriter.h><br>
> #include <itkImageFileReader.h><br>
><br>
> int main(int argc, char* argv[])<br>
> {<br>
><br>
> typedef itk::Image<short, 3> ImageType;<br>
><br>
> if(argc < 3)<br>
> {<br>
> // programName <filename>.nhdr <filename>.nii<br>
> std::cerr << "Usage: " << argv[0] << " Output1.nhdr Output2.nii\n";<br>
> return EXIT_FAILURE;<br>
> }<br>
><br>
> // Read .nhdr file<br>
> typedef itk::ImageFileReader< ImageType > ReaderType;<br>
> ReaderType::Pointer reader = ReaderType::New();<br>
> reader->SetFileName(argv[1]);<br>
> reader->Update();<br>
><br>
> // Save it as nii<br>
> typedef itk::ImageFileWriter< ImageType > WriterType;<br>
> WriterType::Pointer writer = WriterType::New();<br>
> writer->UseInputMetaDataDictionaryOn(); // is this necessary?<br>
> writer->SetInput(reader->GetOutput());<br>
> writer->SetFileName(argv[2]);<br>
><br>
> try<br>
> {<br>
> writer->Update();<br>
> }<br>
> catch(itk::ExceptionObject e)<br>
> {<br>
> std::cout << "Could not save image to file\n";<br>
> }<br>
><br>
> return EXIT_SUCCESS;<br>
> }<br>
><br>
><br>
> --<br>
> "Se podes olhar, vê. Se podes ver, repara."<br>
><br>
> _______________________________________________<br>
> Community mailing list<br>
> <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
> <a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
><br>
--<br>
"Se podes olhar, vê. Se podes ver, repara."<br>
<br>
_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
<br>
<br>
--<br>
"Se podes olhar, vê. Se podes ver, repara."<br>
<br>
_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
</blockquote></div><div dir="ltr">-- <br></div><div><div dir="ltr"><div>"Se podes olhar, vê. Se podes ver, repara."</div></div></div>
</div></div></blockquote></div><br></div>