<div dir="ltr"><div>Apologies, </div><div><br></div>I found the error in my code, now it works!<div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div style="font-size:12.8px"><font face="monospace, monospace">var itkImageJS = new module.itkImageJS();</font></div><div style="font-size:12.8px"><font face="monospace, monospace">console.log("Installing file: ");</font></div><div style="font-size:12.8px"><font face="monospace, monospace">var input_filepath = '/raw/test.nii.gz';</font></div><div style=""><font face="monospace, monospace" style=""><span style="font-size:12.8px">FS.writeFile(input_filepath, <b>new Uint8Array(imagedata)</b>, { encoding: 'binary' });</span></font></div></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px"><font face="monospace, monospace">var stat = FS.stat(input_filepath);//The file exists!<br></font><span style="font-family:monospace,monospace;font-size:12.8px">itkImageJS.ReadImage(input_</span><span style="font-family:monospace,monospace;font-size:12.8px">filepath);</span></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote><br></div><div><font face="monospace, monospace"><span style="font-size:12.8px"><br></span></font></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Best regards, </font></span></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif"><br></font></span></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Juan<br></font></span><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px"><font face="monospace, monospace"><br></font></blockquote></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 3, 2015 at 8:55 PM, Juan Carlos Prieto <span dir="ltr"><<a href="mailto:juanprietob@gmail.com" target="_blank">juanprietob@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">Dear all, <div><br></div><div>I have started using emscripten to develop a plugin to read medical images in the browser.</div><div><br></div><div>I have a compiled version of my code that works in Node.js. </div><div>I am able to read an image, manipulate the data and write the image. </div><div><br></div><div>However, whenever I tried to execute the same code in the browser, the itk::ImageReader seems to be creating a reader for PNG only. </div><div><br></div><div>This is an example code that I am execuitng:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="monospace, monospace">var itkImageJS = new module.itkImageJS();</font></div><div><div><font face="monospace, monospace">console.log("Installing file: ");</font></div></div><div><div><font face="monospace, monospace">var input_filepath = '/raw/test.nii.gz';</font></div></div><div><div><font face="monospace, monospace">FS.writeFile(input_filepath, imagedata, { encoding: 'binary' });</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font face="monospace, monospace">var stat = FS.stat(input_filepath);//The file exists!</font><br></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><font face="monospace, monospace">itkImageJS.ReadImage(input_filepath);</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div></blockquote><font face="arial, helvetica, sans-serif">And this is the output from the exception: </font><div><font face="arial, helvetica, sans-serif"><br></font></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><font face="monospace, monospace">itk::ExceptionObject (0x6a5710)</font></div></div><div><div><font face="monospace, monospace">testFS.js:1 Location: "unknown" </font></div></div><div><div><font face="monospace, monospace">testFS.js:1 File: .../ITK/Modules/IO/PNG/src/itkPNGImageIO.cxx</font></div></div><div><div><font face="monospace, monospace">testFS.js:1 Line: 107</font></div></div><div><div><font face="monospace, monospace">testFS.js:1 Description: itk::ERROR: PNGImageIO(0x975628): PNGImageIO failed to read header for file: </font></div></div><div><div><font face="monospace, monospace">testFS.js:1 Reason: fread read only 0 instead of 8</font></div></div><div><font face="monospace, monospace"><br></font></div></blockquote><font face="arial, helvetica, sans-serif">Instead of creating the reader for a Nifti image, the reader is for PNG image. </font><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Is it possible to read other type of files in the browser?</font></div><div><font face="arial, helvetica, sans-serif">Do I have to read the data server side and stream it to the client?</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Any comments or suggestions will be greatly appreciated. </font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Best regards, </font></div><span class="HOEnZb"><font color="#888888"><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Juan</font></div></font></span></div>
</blockquote></div><br></div>