I’m not 100% sure what’s going on here. I have a slight suspicion your CSF mask may be (or have become) empty at that stage for some reason, but that shouldn’t trip the script up (it should actually give you a nice message about that). After the script crashes like this, could you go the temp folder where the script was running (that should have been reported at the start of the script’s output), and test this command, so we know what’s exactly going on:
PS: I’m not into the details of Python, but it seems the int() function might be tripping up over an emtpy string as input? That’s at least what mrstats outputs when the voxel count in the provided mask is zero… Maybe we should have it output a proper “0” in this case? What do you reckon, @jdtournier and @rsmith ? I’m still surprised this fails though, because the script seems to have been designed to be comfortable with this scenario, and report to the user that one or more tissue masks are empty at this stage…?
Also, what could be the potential causes for an empty CSF mask? I’m processing HCP data and am following the pipeline suggested on the MRtrix3 documentation online.
I need to look into the mrstats behaviour both for this and another similar issue. But you’re right in that the CSF mask derived during the dwi2response msmt_5tt algorithm shouldn’t be empty. My suspicion is that derivation of the 5TT image has somehow gone awry, and the crashing dwi2response call is a downstream effect. Are you able to check that your 5TT image conforms to the expected format and contains the expected information? If you’re unsure, you could run the 5tt2vis command and post a screenshot of the resulting image.
If you’re still running into trouble, note that you can use the dhollander algorithm for this application as well: this one doesn’t require the 5TT image as an input. We’ve used it on a lot of very varied cases (as to acquisition setups, patient groups, subject ages, etc…) in our lab with very good results, and a number of external users have reported good success on the forum here too. Both us, as well as other users, had no issues using it on HCP data as well.
Working with your original reported dwi2response call, you could change it into:
As you suspected, the 5TT segmentation did go wrong. The sub-cortical gray matter turned out to be out of place. I derived it freshly and now it looks okay. Also, the issue with dwi2response seems to have been resolved and it works smoothly.
mrconvert: [ERROR] failed to open key/value file "/Users/sahaa2/Desktop/599671/T1w/Diffusion/5TT.mif": No such file or directory
You need to verify that file 5TT.mif is in fact present in the working directory when you execute the script. Note that the file name is case-sensitive.