Open EliseCos opened 1 month ago
hi Elise -
Thank you for your interest. The link is now corrected in the readme. The www at the start shouldn't be there. The corrected link is: http://users.bmap.ucla.edu/~yeunkim/MBE_weights.tar.gz.
thank you, David
Great thank you !!!
Sorry two questions: can you put these models into the container and also tag the container with a proper release ?
hi Elise -
The models should already be in the container. I just pulled the docker to one of my machines and checked, and they are in the /mod5 directory. The Dockerfile is pulling from a different file than the readme lists, but I ran a diff on the weights and they are the same. The contents of the /mod5 directory are identical to the contents of the MBE_weights directory in the tar file in the readme.
We'll make it consistent and update the files, but it will probably be a couple of weeks before we have an update.
thank you, David
re, I end up with an empty mask. 😞 Here is the command line I try to run:
singularity exec containers/mbe.sif /mousebrainextractor/bin/run_mbe_predict_skullstrip.py -i b107__mean.nii.gz -o /homes_unix/ecosenza/out/mask.nii.gz -d 3 --dstype exvivo -n s/MBE_weights/exvivo/checkpoint_best.pth -m orig
Here is my exvivo image: link
Can you tell me what did I do wrong ?
Thank you in advance Elise
When I try to run the recommanded command line:
singularity run --bind /homes_unix/ecosenza/ containers/mbe.sif -i b107__mean.nii.gz -o out/mask.nii.gz --dstype exvivo
I get this error:
Traceback (most recent call last):
File "/mousebrainextractor/bin/run_mbe_predict_skullstrip_container.py", line 258, in <module>
main()
File "/mousebrainextractor/bin/run_mbe_predict_skullstrip_container.py", line 140, in main
weight = torch.load(modelname, map_location=device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/miniconda3/lib/python3.11/site-packages/torch/serialization.py", line 997, in load
with _open_file_like(f, 'rb') as opened_file:
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/miniconda3/lib/python3.11/site-packages/torch/serialization.py", line 444, in _open_file_like
return _open_file(name_or_buffer, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/miniconda3/lib/python3.11/site-packages/torch/serialization.py", line 425, in __init__
super().__init__(open(name, mode))
^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/mod5/exvivo/checkpoint_best.pth'
Hi Elise -
I took a look at your image, and it looks like you only have brain tissue in the image and all non-brain tissue was removed already. Was this done physically prior to scanning?
The file is named mean -- is this a multi-subject average or an average of the same subject? It also looks like the image has been resampled -- did you align it to a template?
If your goal is to make a brain mask, I don't think you need to run brain extraction on it. A simple threshold operation would work for this, maybe with a few dilations/erosions afterwards to clean up the edges. You can do this interactively in our BrainSuite software and it only takes a couple of seconds. If you want some suggestions on that, it would be a little easier over email (and it's diverging from being an issue for the Mouse Brain Extractor). You can email us at support@brainsuite.org, which goes to me and a few others on our team.
I was able to run MBE on your image, and it pulled out part of the brain. This could probably be improved by running bias correction on the image prior to running MBE, but again I think thresholding is the easiest and fastest approach for this.
I wasn't able to reproduce your error above.
Did you create your own .sif file or rename the one we distribute? We have a singularity image available here: https://users.bmap.ucla.edu/~yeunkim/mbe.img.
I used our mbe.img file:
singularity run --bind $PWD mbe.img -i b107__mean.nii.gz -o out/mask.nii.gz --dstype exvivo
Does the out
folder exist in /homes_unix/ecosenza/
?
thanks, David
I created my own sif file from docker hub and was not able to download your mbe.img file. Can you make it available ? I'm going to give it a try before anything else.
Thank you Elise
hi Elise -
I fixed the link for the singularity image in the readme -- it is http://users.bmap.ucla.edu/~yeunkim/mbe.img.
thanks, David
Hi Elise -
Also, I copied the downloads to a different server that supports https because my browser was not happy with the http link. The new links are
https://mousesuite.org/downloads/mbe/mbe.img
and
https://mousesuite.org/downloads/mbe/MBE_weights.tar.gz
thanks, David
Hi David,
I obtained a mask but it inclues only a small part of the brain. I added in the same folder
Here is the command line that I run :
singularity run --bind /homes_unix/ecosenza/ mbe.img -i ../b107__mean.nii.gz -o ../out/mask.nii.gz --dstype exvivo
Thank you,
Elise
Hi Elise -
Yes, that is the result that I got as well.
The model was trained on data with skull and other non-brain tissue still present in the images, so it really isn't designed for the type of image you are processing. There may be some ways to improve the result (applying N4 prior to running MBE, for example). @yeunkim, who developed the software, may have some other suggestions, but she is unavailable for the next week.
For generating a mask for this type of image, I would recommend just applying a threshold and some morphological operators (dilation/erosion). I've pasted an example below, which took just a few seconds to make.
thanks, David
Hi @yeunkim
I have several brains with not always the same range of values. So I'm looking to automate the extraction and creation of a mask for all brains. If you have other suggestions.
Thank you for your help
Elise
Hi @EliseCos ,
Thank you for your interest in MBE. Just to clarify - you are looking to generate masks using the skull-stripped images (i.e., similar to the image you shared)? If this is the case, you can binarize the brain images by thresholding the image. This is assuming that the background non-brain voxels are zero-valued. You can do so by using BrainSuite, but you can also use other software such as FSL - or even Python.
In any case, if your images are already skull-stripped, MBE is not suitable for your purpose, as its function is to derive masks using whole images with the skull still intact.
Hope this helps! Yeun
@yeunkim - The image wasn't skull-stripped, but it appears to have been acquired on a sample that had all non-brain tissue removed. The non-brain voxels aren't zero, except for at the edges where it's black (presumably because the image has been reoriented).
@EliseCos - If MBE doesn't work on your data, I have a couple of other unreleased programs that might work on them. Can you share a few more images with me?
thanks, David
Hi @dshattuck
You can find in the same folder 4 others brains (some have a lower SNR)
Thank you for your help,
Elise
hi @EliseCos -
I wrote some code that seems to work reasonably well for all of your test images. See below.
thanks, David
Hi @dshattuck Your extractions are awesome ! Can you share your code ? Thank again for your help
Hi @EliseCos -
Yes, happy to help.
Can you send me an email? The code isn't ready for distribution yet, but I can share an early version with you.
thanks, David
Thank you for your share
Here is my email: elise.cosenza@u-bordeaux.fr
Hello @yeunkim @dshattuck ,
Thank you for this amazing tool. It seems that the archive is no longer accessible (MBE_weights.tar.gz) Can you fix this ?
Thank you in advance Elise