diff --git a/fslstats.cc b/fslstats.cc index 1fa45407264fbd0f7dd8ea5c4dc504cce0304f4f..1056bb44842859971c21d258bc5ec9f8a22b9e1a 100644 --- a/fslstats.cc +++ b/fslstats.cc @@ -130,13 +130,15 @@ int generate_masks(volume4D<float> &mask, volume4D<float> &masknz, const volume4 if (!lthr_used) { lthr=vin.min()-1; } if (!uthr_used) { uthr=vin.max()+1; } mask = binarise(vin,lthr,uthr,exclusive); - masknz = mask * (1.0f - binarise(vin,0.0f, 0.0f)); + if (mask.tsize()!=1) masknz = (binarise(vin,0.0f, 0.0f)-1.0f)*-1.0f*mask; + else masknz = (binarise(vin,0.0f, 0.0f)-1.0f)*mask[0]; return 0; } int generate_masks(const volume4D<float> &mask, volume4D<float> &masknz, const volume4D<float> &vin) { - masknz = mask * (1.0f - binarise(vin,0.0f, 0.0f)); + if (mask.tsize()!=1) masknz = (binarise(vin,0.0f, 0.0f)-1.0f)*-1.0f*mask; + else masknz = (binarise(vin,0.0f, 0.0f)-1.0f)*mask[0]; return 0; } @@ -273,7 +275,7 @@ int fmrib_main_float(int argc, char* argv[]) cerr << "Mask and image must be the same size" << endl; exit(3); } - if ( mask.tsize() != vol.tsize() ) { + if ( mask.tsize() != vol.tsize() && mask.tsize() != 1) { // copy the last max volume until the correct size is reached while (mask.tsize() < vol.tsize() ) { mask.addvolume(mask[mask.maxt()]); @@ -290,7 +292,8 @@ int fmrib_main_float(int argc, char* argv[]) mask.binarise(1); } generate_masks(mask,masknz,vin); - vol = vin * mask; + if (mask.tsize()!=1) vol=vin*mask; + else vol=vin*mask[0]; } else if (sarg=="-l") { narg++; if (narg<argc) {