frankkramer-lab / MIScnn

A framework for Medical Image Segmentation with Convolutional Neural Networks and Deep Learning
GNU General Public License v3.0
402 stars 116 forks source link

Prediction Files not loading #64

Open anirban1513 opened 3 years ago

anirban1513 commented 3 years ago

Hello!! I tried to predict a new CT Image with the code below: The prediction image do generate, but I can't open those in a software like 3D slicer! What type of modifications should be done to the code? I used your covid19.MISCNN repo to train the model. And now for prediction, I used this code:

import miscnn from miscnn.data_loading.interfaces.nifti_io import NIFTI_interface import miscnn import tensorflow as tf from miscnn.data_loading.interfaces import NIFTI_interface from miscnn import Data_IO, Preprocessor, Data_Augmentation, Neural_Network from miscnn.processing.subfunctions import Normalization, Clipping, Resampling from miscnn.neural_network.architecture.unet.standard import Architecture from miscnn.neural_network.metrics import tversky_crossentropy, dice_soft, \ dice_crossentropy, tversky_loss

from miscnn.neural_network.model import load

from miscnn.evaluation.cross_validation import cross_validation from tensorflow.keras.callbacks import ReduceLROnPlateau, TensorBoard, \ EarlyStopping, CSVLogger, ModelCheckpoint from miscnn.evaluation.cross_validation import run_fold, load_disk2fold from miscnn.neural_network.architecture.unet.standard import Architecture import argparse import os import json

import tensorflow as tf from miscnn.data_loading.interfaces import NIFTI_interface from miscnn import Data_IO from miscnn.evaluation.cross_validation import split_folds

interface = NIFTI_interface(channels=1, classes=2)

data_path = "dataset" data_io = miscnn.Data_IO(interface, data_path) sample_list = data_io.get_indiceslist() sample_list.sort()

sf_clipping = Clipping(min=-1250, max=250)

sf_normalize = Normalization(mode="grayscale")

sf_resample = Resampling((1.58, 1.58, 2.70))

sf_zscore = Normalization(mode="z-score") sf = [sf_clipping, sf_normalize, sf_resample, sf_zscore]

pp = Preprocessor(data_io, batch_size=2, subfunctions=sf, prepare_subfunctions=True, prepare_batches=False, analysis="patchwise-crop", patch_shape=(160, 160, 80))

pp.patchwise_overlap = (80, 80, 30)

unet_standard = Architecture(depth=4, activation="softmax", batch_normalization=True)

model = Neural_Network(preprocessor=pp, architecture=unet_standard, loss=tversky_crossentropy, metrics=[tversky_loss, dice_soft, dice_crossentropy], batch_queue_size=3, workers=3, learninig_rate=0.001)

model.load("/data/covid19.MIScnn/runs/model.best.hdf5",custom_objects={'tversky_crossentropy':
tversky_crossentropy,'tversky_loss':tversky_loss,'dice_soft':dice_soft,'dice_crossentropy':dice_crossentropy}) model.predict(sample_list,return_output=False)

Here is a sample Predicted CT Image File; volume-covid19-A-0679_ct.nii.gz

muellerdo commented 3 years ago

Discussed in #73. Implemented by @JimHeo, @Deathlymad & @muellerdo. Finalized in 998d6f5392e50f8b9285cd09b2d8b25de9e8ca3d.

muellerdo commented 3 years ago

Hello @anirban1513,

thanks for pointing out this issue.

Could you check out the newest MIScnn version and validate the created NIfTI predictions are now loadable in 3rd party applications like 3Dslicer?

Cheers, Dominik

anirban1513 commented 3 years ago

Ok.. Checking.

On Fri, Apr 16, 2021, 6:17 PM Dominik Müller @.***> wrote:

Hello @anirban1513 https://github.com/anirban1513,

thanks for pointing out this issue.

Could you check out the newest MIScnn version and validate the created NIfTI predictions are now loadable in 3rd party applications like 3Dslicer?

Cheers, Dominik

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/frankkramer-lab/MIScnn/issues/64#issuecomment-821134064, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK42AR3LDBQ7Z3OSTQC6XHDTJATGZANCNFSM4VFEYTAA .