DOSMA
DOSMA copied to clipboard
Adding model to segment bones
Starting a pull request while working on this to get feedback. A few things are done differently than other models.
- Currently loading model + weights from .h5 file (vs. building model & loading weights)
- This requires storing shape of original images used during training, reshaping inputs to that shape, segmenting, and then returning the shape. https://github.com/gattia/DOSMA/blob/adcebe3df0556eaddac95b3d7501d313f361a367/dosma/models/stanford_qdess_bone.py#L180-L215
- Added option to "resample_images" which if True uses this strategy of using the original model (and resampling shape). If False, presumably we will re-build the original model and load the weights. This is essentially a placeholder for me to get code to re-generate the model(s) directly - I was worried at first I had something in the network that wasn't fully convolutional (Dense layer), but I think we are good. Right now this throws an error (will implement in future).
- Use argmax to create a single segmentation of each tissue (instead of thresholding each tissue separately).
- https://github.com/gattia/DOSMA/blob/adcebe3df0556eaddac95b3d7501d313f361a367/dosma/models/stanford_qdess_bone.py#L199
- Added option
connected_only
tomodel.generate_mask
this is because the bones produced a few spurious points in tests. This is on by default for all tissues.- https://github.com/gattia/DOSMA/blob/adcebe3df0556eaddac95b3d7501d313f361a367/dosma/models/stanford_qdess_bone.py#L217
- The model segments medial/lateral tissues separately.
- To keep convention with other models, it then creates a "men" and "tc" tissue that just combines med/lat segments.
- https://github.com/gattia/DOSMA/blob/adcebe3df0556eaddac95b3d7501d313f361a367/dosma/models/stanford_qdess_bone.py#L165-L176
- Also saved the "all" segmentation mask that is a single mask with all tissues (not one-hot/binary).
- https://github.com/gattia/DOSMA/blob/adcebe3df0556eaddac95b3d7501d313f361a367/dosma/models/stanford_qdess_bone.py#L152-L154
- To keep convention with other models, it then creates a "men" and "tc" tissue that just combines med/lat segments.
The main things I see myself wanting to do/add are:
- [ ] Create function to build original model so we can skip resampling images up/down?
- [ ] Add a model using same architecture as other
stanford_qdess.py
models - I think the segmentation performance on this model vs. that are pretty much the same.
@gattia thanks for the PR! could you lint your files and provide some same screenshots of the segmentations
Looks like it's getting hungup during CI because Python 3.6 isn't available anymore?
Performed lint on my side + added a photo of the current segs. I'd love to add the two remaining things I have listed on my PR comments, but they're not necessary for this PR and maybe I can do at a later date.