Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Didn't work with non-dicom data #5

Open
pieper opened this issue Jul 10, 2023 · 5 comments
Open

Didn't work with non-dicom data #5

pieper opened this issue Jul 10, 2023 · 5 comments

Comments

@pieper
Copy link
Collaborator

pieper commented Jul 10, 2023

When I tried running the module on a CT scan from Slicer's SampleData module it failed with this message in the console. It would be better to give a dialog warning that DICOM data is required and then fail gracefully. (or maybe it can work on non-DICOM data?).

Creating SAM predictor ... weights not found
Downloading SAM weights ... Done
Creating SAM predictor ... Done
Traceback (most recent call last):
  File "/home/exouser/Downloads/Slicer-5.3.0-2023-07-08-linux-amd64/slicer.org/Extensions-31860/TomoSAM/lib/Slicer-5.3/qt-scripted-modules/tomosam.py", line 492, in onPushEmbeddingsCreate
    instanceUIDs = volume_node.GetAttribute("DICOM.instanceUIDs").split()
AttributeError: 'NoneType' object has no attribute 'split'
@fedesemeraro
Copy link
Owner

So far we have only tested TomoSAM by importing 3D tif stacks into Slicer. If you convert DICOM into tifs then it should work. I am a bit short on time this week, but I would love your help if you want to extend this limitation to DICOM files

@pieper
Copy link
Collaborator Author

pieper commented Jul 12, 2023

It looks like the issue is this code:

https://github.com/fsemerar/SlicerTomoSAM/blob/b9f5e6d92974292800cf67d93d3f638c35880f6a/TomoSAM/tomosam.py#L486-L497

When you load data from a file there can be a storage node but no DICOM.instanceUIDs so it should be easy to catch this case.

@pieper
Copy link
Collaborator Author

pieper commented Jul 12, 2023

Just to report: I was able to download your tiff file of the CT and was able to calculate the embeddings. But when I add a point I get the following error. The loaded tiff file is selected as the volume node so I'm not sure what's going on.

Traceback (most recent call last):
  File "/home/exouser/Downloads/Slicer-5.3.0-2023-07-08-linux-amd64/slicer.org/Extensions-31860/TomoSAM/lib/Slicer-5.3/qt-scripted-modules/tomosam.py", line 292, in onMarkupIncludePointPositionDefined
    self.addPoint(caller, self.logic.include_coords)
  File "/home/exouser/Downloads/Slicer-5.3.0-2023-07-08-linux-amd64/slicer.org/Extensions-31860/TomoSAM/lib/Slicer-5.3/qt-scripted-modules/tomosam.py", line 353, in addPoint
    self.logic.get_mask(self.first_freeze)
  File "/home/exouser/Downloads/Slicer-5.3.0-2023-07-08-linux-amd64/slicer.org/Extensions-31860/TomoSAM/lib/Slicer-5.3/qt-scripted-modules/tomosamLib/tomosamLogic.py", line 182, in get_mask
    new_mask, _, _ = self.predictor.predict(point_coords=np.array(include_points + exclude_points),
  File "/home/exouser/Downloads/Slicer-5.3.0-2023-07-08-linux-amd64/lib/Python/lib/python3.9/site-packages/segment_anything/predictor.py", line 134, in predict
    raise RuntimeError("An image must be set with .set_image(...) before mask prediction.")
RuntimeError: An image must be set with .set_image(...) before mask prediction.

@fedesemeraro
Copy link
Owner

Thank you for reporting this. Does this happen with the precomputed embeddings as well or only when computing them within TomoSAM?

@pieper
Copy link
Collaborator Author

pieper commented Jul 13, 2023

I'm not sure - I only tried computing them, not downloading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants