MRtrix3 / mrtrix3

MRtrix3 provides a set of tools to perform various advanced diffusion MRI analyses, including constrained spherical deconvolution (CSD), probabilistic tractography, track-density imaging, and apparent fibre density
http://www.mrtrix.org
Mozilla Public License 2.0
294 stars 181 forks source link

reuse piped images? #1938

Open maxpietsch opened 4 years ago

maxpietsch commented 4 years ago

Currently writing transformed images fails when they were piped into mrregister:

mrtransform a.mif -linear A.txt - | mrregister - b.mif -transformed a_at_b.mif
[ERROR] failed to open key/value file "/tmp/mrtrix-tmp-l6zQDP.mif": No such file or directory

Can piped images be reused within the same app without explicitly loading them to memory?

somewhat related to #1806

jdtournier commented 4 years ago

OK, as far as I can tell, it should be reusable as long as the corresponding Header doesn't go out of scope. But as soon as the ImageIO::Pipe::unload() method is called, all bets are off... This method only gets called from ImageIO::Base::close(), which as far as I can tell, only gets called in the Header destructor.

But it does mean that if it was loaded the first time, it will remain loaded until its Header is destroyed. Most of the time, that should be benign since it'll be accessed via memory-mapping - but if you happened to request direct IO with non-matching strides or data type, then it will indeed end remaining in your heap...

I'm not sure what's going on in mrregister that triggers this, maybe you can elaborate?