Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
taigw committed Jan 16, 2024
2 parents d71452e + 0e6b60c commit 39c9583
Show file tree
Hide file tree
Showing 37 changed files with 245 additions and 5,030 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PyMIC: A Pytorch-Based Toolkit for Medical Image Computing

PyMIC is a pytorch-based toolkit for medical image computing with annotation-efficient deep learning. Despite that pytorch is a fantastic platform for deep learning, using it for medical image computing is not straightforward as medical images are often with high dimension and large volume, multiple modalities and difficulies in annotating. This toolkit is developed to facilitate medical image computing researchers so that training and testing deep learning models become easier. It is very friendly to researchers who are new to this area. Even without writing any code, you can use PyMIC commands to train and test a model by simply editing configuration files. PyMIC is developed to support learning with imperfect labels, including semi-supervised and weakly supervised learning, and learning with noisy annotations.
PyMIC is a pytorch-based toolkit for medical image computing with annotation-efficient deep learning. Despite that pytorch is a fantastic platform for deep learning, using it for medical image computing is not straightforward as medical images are often with high dimension and large volume, multiple modalities and difficulies in annotating. This toolkit is developed to facilitate medical image computing researchers so that training and testing deep learning models become easier. It is very friendly to researchers who are new to this area. Even without writing any code, you can use PyMIC commands to train and test a model by simply editing configuration files. PyMIC is developed to support learning with imperfect labels, including semi-supervised, self-supervised, and weakly supervised learning, and learning with noisy annotations.

Currently PyMIC supports 2D/3D medical image classification and segmentation, and it is still under development. If you use this toolkit, please cite the following paper:

Expand All @@ -23,7 +23,7 @@ BibTeX entry:

# Features
PyMIC provides flixible modules for medical image computing tasks including classification and segmentation. It currently provides the following functions:
* Support for annotation-efficient image segmentation, especially for semi-supervised, self-supervised, weakly-supervised and noisy-label learning.
* Support for annotation-efficient image segmentation, especially for semi-supervised, self-supervised, self-supervised, weakly-supervised and noisy-label learning.
* User friendly: For beginners, you only need to edit the configuration files for model training and inference, without writing code. For advanced users, you can customize different modules (networks, loss functions, training pipeline, etc) and easily integrate them into PyMIC.
* Easy-to-use I/O interface to read and write different 2D and 3D images.
* Various data pre-processing/transformation methods before sending a tensor into a network.
Expand All @@ -47,10 +47,10 @@ Run the following command to install the latest released version of PyMIC:
```bash
pip install PYMIC
```
To install a specific version of PYMIC such as 0.4.0, run:
To install a specific version of PYMIC such as 0.4.1, run:

```bash
pip install PYMIC==0.4.0
pip install PYMIC==0.4.1
```
Alternatively, you can download the source code for the latest version. Run the following command to compile and install:

Expand Down
7 changes: 4 additions & 3 deletions pymic/loss/seg/mumford_shah.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

import torch
import torch.nn as nn
from pymic.loss.seg.abstract import AbstractSegLoss

class MumfordShahLoss(nn.Module):
class MumfordShahLoss(AbstractSegLoss):
"""
Implementation of Mumford Shah Loss for weakly supervised learning.
Expand Down Expand Up @@ -76,8 +77,8 @@ def forward(self, loss_input_dict):
image = loss_input_dict['image']
if(isinstance(predict, (list, tuple))):
predict = predict[0]
if(self.softmax):
predict = nn.Softmax(dim = 1)(predict)
if(self.acti_func is not None):
predict = self.get_activated_prediction(predict, self.acti_func)

pred_shape = list(predict.shape)
if(len(pred_shape) == 5):
Expand Down
4 changes: 2 additions & 2 deletions pymic/loss/seg/slsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def forward(self, loss_input_dict):

if(isinstance(predict, (list, tuple))):
predict = predict[0]
if(self.softmax):
predict = nn.Softmax(dim = 1)(predict)
if(self.acti_func is not None):
predict = self.get_activated_prediction(predict, self.acti_func)
predict = reshape_tensor_to_2D(predict)
soft_y = reshape_tensor_to_2D(soft_y)
if(pix_w is not None):
Expand Down
8 changes: 4 additions & 4 deletions pymic/loss/seg/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def forward(self, loss_input_dict):

if(isinstance(predict, (list, tuple))):
predict = predict[0]
if(self.softmax):
predict = nn.Softmax(dim = 1)(predict)
if(self.acti_func is not None):
predict = self.get_activated_prediction(predict, self.acti_func)

# for numeric stability
predict = predict * 0.999 + 5e-4
Expand Down Expand Up @@ -70,8 +70,8 @@ def forward(self, loss_input_dict):

if(isinstance(predict, (list, tuple))):
predict = predict[0]
if(self.softmax):
predict = nn.Softmax(dim = 1)(predict)
if(self.acti_func is not None):
predict = self.get_activated_prediction(predict, self.acti_func)

# for numeric stability
predict = predict * 0.999 + 5e-4
Expand Down
Loading

0 comments on commit 39c9583

Please sign in to comment.