<div dir="ltr">Oh thank you that's very useful information, and I was able to solve the problem of format size. However, there may be a bug with write_mrtrix.m. I simply ran im = read_mrtrix(filename) and then write_mrtrix(im,new_filename) and there is an error: <div>
<br></div><div>Error using fprintf<div>Function is not defined for 'cell' inputs.</div><div><br></div><div>Error in write_mrtrix (line 78)</div><div> fprintf (fid, '\ncomments: %s', image.comments)</div></div>
<div><br></div><div><br></div><div style>Thanks</div><div style><br></div><div style>Evan</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 11, 2013 at 11:14 AM, Donald Tournier <span dir="ltr"><<a href="mailto:d.tournier@brain.org.au" target="_blank">d.tournier@brain.org.au</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Hi Evan,</p>
<p dir="ltr">I just forgot to mention one more thing: the latest release of MRtrix contains Matlab functions to read and write image files in .mif format, in the Matlab folder. Probably better than trying to hack an existing Analyze image...</p>
<p dir="ltr">Cheers,<br>
Donald.</p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On 11 Sep 2013 20:58, "Donald Tournier" <<a href="mailto:d.tournier@brain.org.au" target="_blank">d.tournier@brain.org.au</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr">Hi Evan,</p>
<p dir="ltr">Looks like the file you are generating in Matlab is too small to contain all the data. As you've already noticed, the original size of the dataset is close to 48MB, whereas your file is only about 3MB - I'm guessing it's only one volume out of the 15 required for a lmax 4 file. Not sure why MRtrix didn't catch and report the discrepancy rather than crash, I thought I'd put in checks for that... In any case, your data file is much smaller than expected based on the image header, and this will mean that any attempt to read data past the end of the file will cause an invalid memory access.</p>
<p dir="ltr">Hope that helps.</p>
<p dir="ltr">Cheers,<br>
Donald.<br>
</p>
<div class="gmail_quote">On 11 Sep 2013 06:00, "Evan Schwab" <<a href="mailto:eschwab3@jhu.edu" target="_blank">eschwab3@jhu.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi,<div><br></div><div>Thank you very much in advance. I am trying to visualize my own ODFs with my own calculated coefficients for the SH basis. I create an analyze file and try to mrconvert to a .mif file but I get a segmentation fault. Can you please help me to understand what I'm doing wrong? My debugging process and output is outlined below.</div>
<div><br></div><div>Thanks so much,</div><div><br></div><div>Evan</div><div><br></div><div><br></div><div>To debug I did the following:</div><div><br></div><div>1) I first generate a CSD4.mif file properly by csdeconv.</div>
<div>2) I mrconvert the CSD4.mif to CSD4.img</div><div>3) I read the analyze file into matlab and replace the .img with my own 4D coefficient matrix. For debugging purposes I use here a matrix of all zeros.</div>
<div>4) Then I write this new matrix as a analyze file with the same header information as before.</div><div>5) I mrconvert my .img file to a new .mif file (using the -debug flag)</div><div><br></div><div>
I get the following output:</div><div><br></div><div><div>$ mrconvert -info -debug CSD4_clsArray.img CSD4_clsArray.mif</div><div>mrconvert [DEBUG]: reading key/value file "/etc/mrtrix.conf"...</div><div>
mrconvert [INFO]: opening image "CSD4_clsArray.img"...</div><div>mrconvert [DEBUG]: preparing file "./CSD4_clsArray.hdr"</div><div>mrconvert [DEBUG]: file "./CSD4_clsArray.hdr" mapped at 0x7feb2e267000, size 348 (read-only)</div>
<div>mrconvert [INFO]: assuming Analyse images are encoded left to right</div><div>mrconvert [DEBUG]: preparing file "./CSD4_clsArray.img"</div><div>mrconvert [DEBUG]: unmapping file "./CSD4_clsArray.hdr"</div>
<div>mrconvert [DEBUG]: setting up image "CSD4_clsArray.img"...</div><div>mrconvert [DEBUG]: sanitising transformation matrix...</div><div>mrconvert [DEBUG]: setting up data increments for "CSD4_clsArray.img"...</div>
<div>mrconvert [DEBUG]: data increments initialised with start = 0, stride = [ 1 112 12544 815360 ]</div><div>mrconvert [DEBUG]: mapping image "CSD4_clsArray.img"...</div><div>mrconvert [DEBUG]: file "./CSD4_clsArray.img" mapped at 0x7feb2b206000, size 3261440 (read-only)</div>
<div>mrconvert [DEBUG]: data mapper for image "CSD4_clsArray.img" mapped with segment size = 12230400 (optimised)</div><div>mrconvert [INFO]: creating image "CSD4_clsArray.mif"...</div><div>mrconvert [DEBUG]: preparing file "./CSD4_clsArray.mif"</div>
<div>mrconvert [DEBUG]: setting up image "./CSD4_clsArray.mif"...</div><div>mrconvert [DEBUG]: sanitising transformation matrix...</div><div>mrconvert [DEBUG]: setting up data increments for "./CSD4_clsArray.mif"...</div>
<div>mrconvert [DEBUG]: data increments initialised with start = 0, stride = [ 1 112 12544 815360 ]</div><div>mrconvert [DEBUG]: mapping image "./CSD4_clsArray.mif"...</div><div>mrconvert [DEBUG]: file "./CSD4_clsArray.mif" mapped at 0x7feb2835e000, size 48921913 (read-write)</div>
<div>mrconvert [DEBUG]: data mapper for image "./CSD4_clsArray.mif" mapped with segment size = 12230400 (optimised)</div><div><br></div><div><br></div><div>As well I have the output when I mrconvert the original CSD4.img back to .mif and the only difference is the line I have labeled as (********) related to the size of the file.</div>
<div><br></div><div><div>$ mrconvert -info -debug CSD4.img CSD42.mif</div><div>mrconvert [DEBUG]: reading key/value file "/etc/mrtrix.conf"...</div><div>mrconvert [INFO]: opening image "CSD4.img"...</div>
<div>mrconvert [DEBUG]: preparing file "./CSD4.hdr"</div><div>mrconvert [DEBUG]: file "./CSD4.hdr" mapped at 0x7f5bcdc81000, size 348 (read-only)</div><div>mrconvert [INFO]: assuming Analyse images are encoded left to right</div>
<div>mrconvert [DEBUG]: preparing file "./CSD4.img"</div><div>mrconvert [DEBUG]: unmapping file "./CSD4.hdr"</div><div>mrconvert [DEBUG]: setting up image "CSD4.img"...</div><div>mrconvert [DEBUG]: sanitising transformation matrix...</div>
<div>mrconvert [DEBUG]: setting up data increments for "CSD4.img"...</div><div>mrconvert [DEBUG]: data increments initialised with start = 0, stride = [ 1 112 12544 815360 ]</div><div>mrconvert [DEBUG]: mapping image "CSD4.img"...</div>
<div>(********) mrconvert [DEBUG]: file "./CSD4.img" mapped at 0x7f5bc8095000, size 48921600 (read-only)</div><div>mrconvert [DEBUG]: data mapper for image "CSD4.img" mapped with segment size = 12230400 (optimised)</div>
<div>mrconvert [INFO]: creating image "CSD42.mif"...</div><div>mrconvert [DEBUG]: preparing file "./CSD42.mif"</div><div>mrconvert [DEBUG]: setting up image "./CSD42.mif"...</div><div>mrconvert [DEBUG]: sanitising transformation matrix...</div>
<div>mrconvert [DEBUG]: setting up data increments for "./CSD42.mif"...</div><div>mrconvert [DEBUG]: data increments initialised with start = 0, stride = [ 1 112 12544 815360 ]</div><div>mrconvert [DEBUG]: mapping image "./CSD42.mif"...</div>
<div>mrconvert [DEBUG]: file "./CSD42.mif" mapped at 0x7f5bc51ed000, size 48921913 (read-write)</div><div>mrconvert [DEBUG]: data mapper for image "./CSD42.mif" mapped with segment size = 12230400 (optimised)</div>
<div>mrconvert: copying data... 100%</div><div>mrconvert [INFO]: closing image "CSD4.img"...</div><div>mrconvert [DEBUG]: unmapping file "./CSD4.img"</div><div>mrconvert [INFO]: closing image "./CSD42.mif"...</div>
<div>mrconvert [DEBUG]: unmapping file "./CSD42.mif"</div><div><br></div></div></div></div>
<br>_______________________________________________<br>
Mrtrix-discussion mailing list<br>
<a href="mailto:Mrtrix-discussion@www.nitrc.org" target="_blank">Mrtrix-discussion@www.nitrc.org</a><br>
<a href="http://www.nitrc.org/mailman/listinfo/mrtrix-discussion" target="_blank">http://www.nitrc.org/mailman/listinfo/mrtrix-discussion</a><br>
<br></blockquote></div>
</blockquote></div>
</div></div></blockquote></div><br></div>