Coder Social home page Coder Social logo

dltk / dltk Goto Github PK

View Code? Open in Web Editor NEW
1.4K 101.0 404.0 19.05 MB

Deep Learning Toolkit for Medical Image Analysis

Home Page: https://dltk.github.io/

License: Apache License 2.0

Python 100.00%
deep-learning machine-learning neural-networks tensorflow medical-imaging data-science ml deep-neural-networks python medical

dltk's Introduction

Deep Learning Toolkit (DLTK) for Medical Imaging

Gitter Coverage Status Build Status

DLTK logo

DLTK is a neural networks toolkit written in python, on top of TensorFlow. It is developed to enable fast prototyping with a low entry threshold and ensure reproducibility in image analysis applications, with a particular focus on medical imaging. Its goal is to provide the community with state of the art methods and models and to accelerate research in this exciting field.

Documentation

The DLTK API can be found here

Referencing and citing DLTK

If you use DLTK in your work please refer to this citation for the current version:

@article{pawlowski2017state,
  title={DLTK: State of the Art Reference Implementations for Deep Learning on Medical Images},
  author={Nick Pawlowski and S. Ira Ktena, and Matthew C.H. Lee and Bernhard Kainz and Daniel Rueckert and Ben Glocker and Martin Rajchl},
  journal={arXiv preprint arXiv:1711.06853},
  year={2017}
}

If you use any application from the DLTK Model Zoo, additionally refer to the respective README.md files in the applications' folder to comply with its authors' instructions on referencing.

Introduction to Biomedical Image Analysis

To ease into the subject, we wrote a quick overview blog entry (12 min read) for the new TensorFlow blog. It covers some of the speciality information required for working with medical images and we suggest to read it, if you are new to the topic. The code we refer to in the blog can be found in examples/tutorials and examples/applications.

Installation

  1. Setup a virtual environment and activate it. Although DLTK<=0.2.1 supports and python 2.7, we will not support it future releases, similarly to our dependencies (i.e. SciPy, NumPy). We highly recommend using python3. If you intend to run this on machines with different system versions, use the --always-copy flag:

    virtualenv -p python3 --always-copy venv_tf
    source venv_tf/bin/activate
  2. Install TensorFlow (>=1.4.0) (preferred: with GPU support) for your system as described here:

    pip install "tensorflow-gpu>=1.4.0"
  3. Install DLTK: There are two installation options available: You can simply install dltk as is from pypi via

    pip install dltk

    or you can clone the source and install DLTK in edit mode (preferred):

    cd MY_WORKSPACE_DIRECTORY
    git clone https://github.com/DLTK/DLTK.git 
    cd DLTK
    pip install -e .

    This will allow you to modify the actual DLTK source code and import that modified source wherever you need it via import dltk.

Start playing

  1. Downloading example data You will find download and preprocessing scripts for publicly available datasets in data. To download the IXI HH dataset, navigate to data/IXI_HH and run the download script with python download_IXI_HH.py.

  2. Tutorial notebooks In examples/tutorials you will find tutorial notebooks to better understand on how DLTK interfaces with TensorFlow, how to write custom read functions and how to write your own model_fn.

    To run a notebook, navigate to the DLTK source root folder and open a notebook server on MY_PORT (default 8888):

    cd MY_WORKSPACE_DIRECTORY/DLTK
    jupyter notebook --ip=* --port MY_PORT

    Open a browser and enter the address http://localhost:MY_PORT or http://MY_DOMAIN_NAME:MY_PORT. You can then navigate to a notebook in examples/tutorials, open it (c.f. extension .ipynb) and modify or run it.

  3. Example applications There are several example applications in examples/applications using the data in 1. Each folder contains an experimental setup with an application. Please note that these are not tuned to high performance, but rather to showcase how to produce functioning scripts with DLTK models. For additional notes and expected results, refer to the notes in the individual example's README.md.

DLTK Model Zoo

We also provide a zoo with (re-)implementations of current research methodology in a separate repository DLTK/models. Each model in the zoo is maintained by the respective authors and implementations often differ to those in examples/applications. For instructions and information on the individual application in the zoo, please refer to the respective README.md files.

How to contribute

We appreciate any contributions to the DLTK and its Model Zoo. If you have improvements, features or patches, please send us your pull requests! You can find specific instructions on how to issue a PR on github here. Feel free to open an issue if you find a bug or directly come chat with us on our gitter channel Gitter.

Basic contribution guidelines

  • Python coding style: Like TensorFlow, we loosely adhere to google coding style and google docstrings.
  • Entirely new features should be committed to dltk/contrib before we can sensibly integrate it into the core.
  • Standalone problem-specific applications or (re-)implementations of published methods should be committed to the DLTK Model Zoo repo and provide a README.md file with author/coder contact information.

Running tests locally

To run the tests on your machine, you can install the tests extras by running pip install -e '.[tests]' inside the DLTK root directory. This will install all necessary dependencies for testing. You can then run pytest --cov dltk --flake8 --cov-append to see whether your code passes.

Building docs locally

To run the tests on your machine, you can install the docs extras by running pip install -e '.[docs]' inside the DLTK root directory. This will install all necessary dependencies for the documentation. You can then run make -C docs html to build the documentation. You can access this documentation in a web browser of your choice by pointing it at docs/build/html/index.html.

The team

DLTK is currently maintained by @pawni and @mrajchl with greatly appreciated contributions coming from individual researchers and engineers listed here in alphabetical order: @CarloBiffi @ericspod @ghisvail @mauinz @michaeld123 @sk1712

License

See LICENSE

Acknowledgments

We would like to thank NVIDIA GPU Computing for providing us with hardware for our research.

dltk's People

Contributors

ericspod avatar fepegar avatar ghisvail avatar michaeld123 avatar mrajchl avatar pawni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dltk's Issues

Dice computation in case truth label is missing

I'll open this issue to reference an outdated PR eaa9476 . The question is what the return value should be in case the truth label is missing in that example.

Typically, it should return NaN (as in convert3d), however this complicates most applications and it is currently (suboptimally) handled like this for metrics:

tmp_den if tmp_den > 0 else 1.

I suggest handling this as in dltk.core.losses:

if only_present:

I'll leave this issue open for discussion until resolved.

Error while training with different number of filters

I'm using DLTK package. In the path
DLTK-master\examples\applications\IXI_HH_age_regression_resnet, the train.py got errors. I have resized the images to 646464, and just decreased the filters to filters=(8, 16, 32), (instead of (16, 32, 64, 128, 256)). Also, I changed the resnet.py parameters to match with the parameters in train.py.

But I have got this error:

Assign requires shapes of both tensors to match. lhs shape= [3,3,3,1,8] rhs shape= [3,3,3,1,16]
[[node save/Assign_2 (defined at E:/UT Projects/khanom Dr.Sajedi/DLTK-master/examples/applications/IXI_HH_age_regression_resnet/train.py:191) = Assign[T=DT_FLOAT, _class=["loc:@conv3d/kernel"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](conv3d/kernel, save/RestoreV2:2)]]

Assign requires shapes of both tensors to match. lhs shape= [3,3,3,1,8] rhs shape= [3,3,3,1,16]
[[node save/Assign_2 (defined at E:/UT Projects/khanom Dr.Sajedi/DLTK-master/examples/applications/IXI_HH_age_regression_resnet/train.py:191) = Assign[T=DT_FLOAT, _class=["loc:@conv3d/kernel"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](conv3d/kernel, save/RestoreV2:2)]]

I don't know what is wrong with the tensor shapes. Would anyone help me please?

ERROR extracting IXI HH Data from t1.tar

System : Ubuntu Server 18.04
Python : 2.7
All of prerequisites installed.

While running /data/download_IXI_HH.py, the script throws

Extracting IXI HH data from t2.tar.
Extracting IXI HH data from mra.tar.
Extracting IXI HH data from pd.tar.
Extracting IXI HH data from t1.tar.
[u'Table', u'Ethnicity', u'Marital Status', u'Occupation', u'Qualification', u'Study Date']
download_IXI_HH.py:139: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.
  na_values=[]).as_matrix()
Resampling IXI012
Traceback (most recent call last):
  File "download_IXI_HH.py", line 150, in <module>
    t1 = sitk.ReadImage(t1_fn)
  File "/home/bijayregmi/.local/lib/python2.7/site-packages/SimpleITK/SimpleITK.py", line 8876, in ReadImage
    return _SimpleITK.ReadImage(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'ReadImage'.
  Possible C/C++ prototypes are:
    itk::simple::ReadImage(std::vector< std::string,std::allocator< std::string > > const &,itk::simple::PixelIDValueEnum,std::string const &)
    itk::simple::ReadImage(std::string const &,itk::simple::PixelIDValueEnum,std::string const &)

Question on Distributed training

I'm trying to run one of the DLTK sample on 3 nodes Distributed Training but get stuck at
nn.train( input_fn=train_input_fn,
hooks=[train_qinit_hook, step_cnt_hook],
steps=EVAL_EVERY_N_STEPS)
forever and without any error. Would anyone has idea or something I missed?

My cluster spec is like this and I've ps, chief, and worker tasktype defined correctly
TF_CONFIG: {"cluster": {"ps": ["10.0.0.5:2222"], "chief": ["10.0.0.5:2223"], "worker": ["10.0.0.6:2222", "10.0.0.4:2222"]}, "task": {"type": "ps", "index": 0}, "environment": "cloud"}

DLTK's implementation of DeepMedic underperforms original.

Hello,

Let us note here to the users that DLTK's implementation of DeepMedic is significantly underperforming the original implementation (publicly available at link).

If users seek to evaluate performance of DeepMedic, eg to find the capabilities of the model, compare with other methods, etc, they must use the original version.

Please leave this issue open until the implementation of this version is brought on par with the original.

Thank you,
Konstantinos Kamnitsas

ValueError: Dimensions must be equal, but... - IXI_HH_sex_classification_resnet

I have been experiencing with (https://github.com/DLTK/DLTK/tree/master/examples/applications/IXI_HH_sex_classification_resnet), I made all the changes necessary in both reader.py and train.py in order to run both my .csv and my .nii images and it was going great. Then I realized I had the option 'extract_examples' as True in reader_params in train.py, since I want my 3D network to be trained on the full images I switched it to False and now I am having a "dimensions problem".

I have CT scans with dimensions [X, 512,512] where X, the number of slices, can be any number between 400 and 800. The message preceding code exit 1 is the following (happens during the 1st image):

WARNING:tensorflow:From C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\dltk\networks\regression_classification\resnet.py:77: conv3d (from tensorflow.python.layers.convolutional) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.conv3d instead.
WARNING:tensorflow:From C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\dltk\core\residual_unit.py:71: max_pooling3d (from tensorflow.python.layers.pooling) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.max_pooling3d instead.
WARNING:tensorflow:From C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\dltk\core\residual_unit.py:80: batch_normalization (from tensorflow.python.layers.normalization) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.batch_normalization instead.
Traceback (most recent call last):
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow\python\framework\ops.py", line 1659, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 63 and 62 for 'unit_3_0/sub_unit_add/add' (op: 'Add') with input shapes: [?,63,64,64,128], [?,62,64,64,128].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Utilizador/PycharmProjects/TesePython36/main.py", line 211, in
steps=EVAL_EVERY_N_STEPS)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 358, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1124, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1154, in _train_model_default
features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1112, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "C:/Users/Utilizador/PycharmProjects/TesePython36/main.py", line 63, in model_fn
kernel_regularizer=tf.contrib.layers.l2_regularizer(1e-3))
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\dltk\networks\regression_classification\resnet.py", line 95, in resnet_3d
mode=mode)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\dltk\core\residual_unit.py", line 120, in vanilla_residual_unit_3d
x += orig_x
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow\python\ops\math_ops.py", line 812, in binary_op_wrapper
return func(x, y, name=name)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 375, in add
"Add", x=x, y=y, name=name)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow\python\framework\ops.py", line 3300, in create_op
op_def=op_def)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow\python\framework\ops.py", line 1823, in init
control_input_ops)
File "C:\Users\Utilizador\Anaconda3\envs\TesePython36\lib\site-packages\tensorflow\python\framework\ops.py", line 1662, in _create_c_op
raise ValueError(str(e))
ValueError: Dimensions must be equal, but are 63 and 62 for 'unit_3_0/sub_unit_add/add' (op: 'Add') with input shapes: [?,63,64,64,128], [?,62,64,64,128].

It is my understanding that the network only takes some defined image sizes, problem is, even after reading the 2 papers referenced in the documentation, I still can't find this sizes.
I am using python 3.6.8, tensorflow 1.13.1 and dltk 0.2.1. Any idea how I can solve this?

Thank you!

Python 3 bug in image summaries during plt.imshow

Running the train.py from MRBrainS13_segmentation throws the following error during plt.imshow in summaries.py

File "train.py", line 278, in
train(args)
File "train.py", line 231, in train
sv.summary_computed(s, modules.image_summary(val_x[0], 'val_img'), global_step=step)
File "....summaries.py", line 90, in image_summary
plt.imsave(s, img[slicer], format='png')
...
...
_png.write_png(im, fname)
TypeError: string argument expected, got 'bytes'

This is the second time I've run into a ' string argument expected, got 'bytes'' error with Python 3. It seems to be solved by replacing StringIO() with BytesIO() throughout summaries.py - see

https://stackoverflow.com/questions/32075135/python-3-in-memory-zipfile-error-string-argument-expected-got-bytes

Could you add a deploy function to the superresolution project?

I have to test my own images with the superresolution functon, but I found it hard to deal with it because the pre-processing of image(average_pooling3d) transformed it into tensor. Could you write a deploy program of superresolution, or tell me how to write? Thank you.

a question related to Lung Nodule Malignancy(LNM) dataset in kaggle

Dear Professor Kevin:
I am confused about that whether the Lung Nodule Malignancy dataset contains the nodule of benign and malignancy? Could I understand the part of benign as the pircture has no nodule? And the part of malignancy contains picture which has nodule? Thank you in advance.
Warm regards Bill from China.

Apply the same transformation to image and mask in elastic_transform ?

In augmentation, elastic_transform, it only applies a random transform on one input image array. I would think to be used for training, the image and mask pair should be transform in the same way. However, this single-input-image, single-output-image method makes it very inconvenient. Could we deform a list of images (np.arrays) using the same transformation in this method ? Thanks!

example sitk readers expect str args in py2

got error Wrong number or type of arguments for overloaded function 'ReadImage'. Possible C/C++ prototypes are: itk::simple::ReadImage(std::vector< std::string,std::allocator< std::string > > const &,itk::simple::PixelIDValueEnum) itk::simple::ReadImage(std::string const &,itk::simple::PixelIDValueEnum) from _read_sample`:
Traceback (most recent call last):
File "/vol/medic01/users/mrajchl/repos/DLTK/src/dltk/io/abstract_reader.py", line 115, in f
ex = next(fn)
File "/vol/medic01/users/mrajchl/repos/DLTK/src/examples/applications/MRBrainS13_tissue_segmentation/reader.py", line 47, in read_fn
t1_sitk = sitk.ReadImage(os.path.join(str(img_fn), 'T1.nii'))

Stability of WGANs

I noticed some issues with the WGANs, I noticed a few things that could do with changing, I'm working on a fix now. Will update on progress

Image and label shape must match in extract_class_balanced_example_array()

Hi,

I'm experiencing an issue with the balanced sampler.

Full image (NumPy array) is shape (130, 164, 145, 1). Segmentation is identical.

If we look at the source code of the function, it seems it fails on the first assert.

My goal was to use this function to get a balanced set of 3D patches of shape (64, 64, 64). Is it possible ?

Thanks,

Pierre-Luc

RuntimeError: generator raised StopIteration - IXI_HH_sex_classification_resnet

I'm trying to run IXI_HH_sex_classification_resnet. I have managed to adapt the reader.py to my particular case but when I tried running train.py, the following error arose:

`2019-06-07 16:08:54.017597: W tensorflow/core/framework/op_kernel.cc:1389] Unknown: RuntimeError: generator raised StopIteration
Traceback (most recent call last):

File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\dltk\io\abstract_reader.py", line 115, in f
ex = next(fn)

StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\ops\script_ops.py", line 207, in call
ret = func(*args)

File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 449, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))

RuntimeError: generator raised StopIteration

Traceback (most recent call last):
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\client\session.py", line 1334, in _do_call
return fn(*args)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\client\session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\client\session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.UnknownError: RuntimeError: generator raised StopIteration
Traceback (most recent call last):

File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\dltk\io\abstract_reader.py", line 115, in f
ex = next(fn)

StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\ops\script_ops.py", line 207, in call
ret = func(*args)

File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 449, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))

RuntimeError: generator raised StopIteration

 [[{{node PyFunc}}]]
 [[{{node IteratorGetNext}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Utilizador/PycharmProjects/TesePrimeiraTentativa/main.py", line 203, in
steps=EVAL_EVERY_N_STEPS)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 358, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1124, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1158, in _train_model_default
saving_listeners)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1407, in _train_with_estimator_spec
_, loss = mon_sess.run([estimator_spec.train_op, estimator_spec.loss])
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\training\monitored_session.py", line 676, in run
run_metadata=run_metadata)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1171, in run
run_metadata=run_metadata)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1270, in run
raise six.reraise(*original_exc_info)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1255, in run
return self._sess.run(*args, **kwargs)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1327, in run
run_metadata=run_metadata)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1091, in run
return self._sess.run(*args, **kwargs)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\client\session.py", line 929, in run
run_metadata_ptr)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\client\session.py", line 1328, in _do_run
run_metadata)
File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\client\session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.UnknownError: RuntimeError: generator raised StopIteration
Traceback (most recent call last):

File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\dltk\io\abstract_reader.py", line 115, in f
ex = next(fn)

StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\ops\script_ops.py", line 207, in call
ret = func(*args)

File "C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 449, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))

RuntimeError: generator raised StopIteration

 [[{{node PyFunc}}]]
 [[node IteratorGetNext (defined at C:\Users\Utilizador\Anaconda3\envs\TensorFlow-GPU-Kera\lib\site-packages\dltk\io\abstract_reader.py:140) ]]

Process finished with exit code 1
`

I believe it can be one of two things:

  1. A version incompatibility error: python 3.7.3; dltk 0.2.1; tensorboard 1.13.1; tensorflow-estimator 1.13.0; tensorflow-gpu 1.13.1)
  2. A memory error: when "Reading" the last image, the following text is outputed

2019-06-07 16:08:21.286693: W tensorflow/core/common_runtime/bfc_allocator.cc:211] Allocator (GPU_0_bfc) ran out of memory trying to allocate 585.09MiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2019-06-07 16:08:21.319659: W tensorflow/core/common_runtime/bfc_allocator.cc:211] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.27GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2019-06-07 16:08:21.490547: W tensorflow/core/common_runtime/bfc_allocator.cc:211] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.27GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2019-06-07 16:08:21.649967: W tensorflow/core/common_runtime/bfc_allocator.cc:211] Allocator (GPU_0_bfc) ran out of memory trying to allocate 585.09MiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.

download_IXI_HH.py fails to read images

When I run "download_IXI_HH.py" I ran into an error when reading the images (line 150). I discovered that this occurred because the file paths were not being read as strings. I manually changed this and the code ran properly. I have attached the modified file:

download_IXI_HH.txt

Grad-Cam

Are you planning to add grad-cam and other heat maps to the package by any chance?

Assert Syntax Incorrect

I've encountered in a number of cases the syntax for the assert statement is incorrect and therefore are not being checked. An assert is a statement and not a function, it should be of the form "assert C [, M]" where C is a condition and M an optional message.

In a number of places the syntax "assert (C,M)" is used which equates to the tuple (C,M) being used as the condition expression. Non-empty tuples always evaluate to True thus these assert statements always succeed and never check C.

If the syntax "assert (C)" is used instead then (C) is an expression rather than a tuple and is correctly checked in that instance however I would say is still bad style.

Saliency/activation map

Hi,

First of all thanks for contributing such a nice framework, this is very appreciated!

I have been playing with the example IXI_HH_sex_classification_resnet and I wonder if you would have any pointer on how I could produce saliency/activation maps which highlight in a test image what where the main areas of interest for the classification problem.

This is not an issue per se : )

Thanks a lot!

Best regards

Compatibility for TF2+

Are there plans for feature extension for this project? If yes, are there plans to support TF2 syntax?

Python 3 _read_sample str/bytes conversion error

Taking train.py from MRBrainS13_segmentation MRBrainS13_segmentation as an example. Training and validation data are read in as arrays of strings, but somewhere the training data is converted to an array of bytes. This is (I assume) why in _read_sample the pathnames are converted back from bytes to strings using path_list[0].decode('UTF-8'), but for Python 3 anyway, I'm finding this causes an error when reading validation paths, which remain as strings. I've hacked a solution to _read_sample as:

path_list = id_queue[0]

    if(isinstance(path_list[0],(bytes))): ## hack until I find why DLTK is converting string to bytes
        path_list_dir=path_list[0].decode('UTF-8')
    else:
        path_list_dir=path_list[0]

    # Use a SimpleITK reader to load the multi channel nii images and labels for training 
    t1 = sitk.GetArrayFromImage(sitk.ReadImage(os.path.join(str(path_list_dir), 'T1.nii')))
    t1_ir = sitk.GetArrayFromImage(sitk.ReadImage(os.path.join(str(path_list_dir), 'T1_IR.nii')))
    t2_fl = sitk.GetArrayFromImage(sitk.ReadImage(os.path.join(str(path_list_dir), 'T2_FLAIR.nii')))
    lbl = sitk.GetArrayFromImage(sitk.ReadImage(os.path.join(str(path_list_dir), 'LabelsForTraining.nii')))

Segmentation with 2 modalities

Hi, I am trying to modify the example of the segmentation for 2 modalities.

In train I have modified the number of channels to 2, and in the reader

'x_train, y_train = reader.MRBrainsReader([tf.float32, tf.int32], [[24, 64, 64, 2], [24, 64, 64]], name='train_queue')( train_files, batch_size=batch_size, n_examples=18, min_queue_examples=batch_size * 2, capacity=batch_size * 4)'

In the mrbrains_reader I have modified this:

data = self._preprocess([t1,t2_fl])

However I get this error.
Tensor must be 4-D with last dim 1, 3, or 4, not [10,64,64,2]

I have tried with only one modality and it works. Could you please sir tell me what to modify?

Thanking you, Chuan.

sliding_window inference outputs nans

When running sliding window inference on data input size (1, 217, 274, 202, 1) the prediction returns nans. This seems to be fixed by changing line ~L137 in utils.py (the sliding window function) to striding = (list(np.maximum(1, np.array(op_bshape) // 2)) if all(out_diff == 0) else op_bshape)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.