From 4a47814686284871733d1406b51016eb712dd09a Mon Sep 17 00:00:00 2001 From: Matthew Webster <mwebster@fmrib.ox.ac.uk> Date: Fri, 6 Feb 2009 15:18:28 +0000 Subject: [PATCH] original behaviour but with much better ram profile for masking --- fslstats.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fslstats.cc b/fslstats.cc index 8d6e5bf..eb528b4 100644 --- a/fslstats.cc +++ b/fslstats.cc @@ -119,20 +119,27 @@ double nonzerostddev(const volume4D<float>& vol) return std::sqrt(var); } -int generate_masks(volume4D<float> &mask, volume4D<float> &masknz, const volume4D<float> &vin, - float& lthr, float& uthr) +int generate_masks(volume4D<float> &mask, volume4D<float> &masknz, const volume4D<float> &vin,float& lthr, float& uthr) { if (!lthr_used) { lthr=vin.min()-1; } if (!uthr_used) { uthr=vin.max()+1; } mask = binarise(vin,lthr,uthr,exclusive); - if (mask.tsize()!=1) masknz = (binarise(vin,0.0f, 0.0f)-1.0f)*-1.0f*mask; + if (mask.tsize()!=1) { + masknz.reinitialize(mask.xsize(),mask.ysize(),mask.zsize(),mask.tsize()); + for (int t=mask.mint(); t<=mask.maxt(); t++) + masknz[t]=((binarise(vin[t],0.0f, 0.0f)-1.0f)*-1.0f*mask[t]); + } else masknz = (binarise(vin,0.0f, 0.0f)-1.0f)*-1.0f*mask[0]; return 0; } int generate_masks(const volume4D<float> &mask, volume4D<float> &masknz, const volume4D<float> &vin) { - if (mask.tsize()!=1) masknz = (binarise(vin,0.0f, 0.0f)-1.0f)*-1.0f*mask; + if (mask.tsize()!=1) { + masknz.reinitialize(mask.xsize(),mask.ysize(),mask.zsize(),mask.tsize()); + for (int t=mask.mint(); t<=mask.maxt(); t++) + masknz[t]=((binarise(vin[t],0.0f, 0.0f)-1.0f)*-1.0f*mask[t]); + } else masknz = (binarise(vin,0.0f, 0.0f)-1.0f)*-1.0f*mask[0]; return 0; } -- GitLab