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

Prediction Files not loading #64

Open
anirban1513 opened this issue Dec 22, 2020 · 3 comments
Open

Prediction Files not loading #64

anirban1513 opened this issue Dec 22, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@anirban1513
Copy link

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
Copy link
Member

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

@muellerdo muellerdo reopened this Apr 16, 2021
@muellerdo
Copy link
Member

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
Copy link
Author

anirban1513 commented Apr 16, 2021 via email

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

No branches or pull requests

2 participants