diff --git a/fslstats.cc b/fslstats.cc index 8d6e5bf8f52453f0711624cf832b53ffbc35a43b..eb528b401b8bf34cedf239721624bf0afbb13c63 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; }