Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

NiftyNet FAQ

Wenqi Li edited this page May 14, 2019 · 26 revisions

How to install the latest version of NiftyNet with pip (a package manager for Python packages)?

The latest version is available at the dev branch of the GitHub repository. This could be installed with pip commands:

pip install -r https://raw.githubusercontent.com/NifTK/NiftyNet/dev/requirements-gpu.txt
pip install git+https://github.com/NifTK/NiftyNet.git

You could also install the optional dependencies:

pip install scikit-image
pip install SimpleITK

To verify the installation,net_run --version should return a version stringNiftyNet version x.x.x+xxxx.

How to export the meta-graph as a file after training a model?

The meta-graph can be exported by adding a tf.train.export_meta_graph command after session initialisation https://github.com/NifTK/NiftyNet/blob/v0.3.0/niftynet/engine/application_driver.py#L402 and running net_segment inference ... (See also: https://www.tensorflow.org/api_guides/python/meta_graph).

Note that if you run the network inside of NiftyNet, the meta file is not needed since NiftyNet recreates the graph in Python code. If you are aiming to run the network outside of NiftyNet, the meta file exported should let you do that, but you will need to be careful to feed data that matches the preprocessing done by NiftyNet.

What are the configuration parameters -- spatial_window_size, volume_padding_size, border, loss_border, and their interactions?

Please see:

How to do cross-validation experiments?

An example is presented at https://github.com/NifTK/NiftyNet/issues/110.

How to finetune a model downloaded from the model zoo?

Does the augmentation layer increase the number of training samples?

All random augmentation layers will be applied to each of the original samples, without generating new ones. The number of training samples is always "batch_size x number of iterations x num_gpus". Please see the demo of visualising the augmented samples: https://github.com/NifTK/NiftyNet/blob/dev/demos/unet/U-Net_Demo.ipynb.

Error message: indices are out-of-bounds w.r.t. dense side with broadcasted shape when training

https://github.com/NifTK/NiftyNet/issues/8

After the inference is done on the image, what's a good way of accessing the Numpy version of the image?

It's in NIfTI format, one option would be using NiBabel (http://nipy.org/nibabel/nibabel_images.html#getting-the-image-data-the-easy-way):

import nibabel
numpy_array = nibabel.load_data('image.nii.gz').get_data()

Shape of numpy_array is [width, height, depth, time, num_channels].

Using NiftyNet with Gradient Checkpointing

Integration of OpenAI's gradient checkpointing in NiftyNet was attempted twice (once here: NiftyNet CMIClab repo, and again here: NiftyNet fork). While it is technically possible, i.e., it's easy to find a suitable hook for monkey patching the gradient functions, the gradient checkpointing code is compatible with the version of Tensorflow used by NiftyNet, etc., none of the NiftyNet networks that were tested were amenable for automatic checkpoint extraction with gradient-checkpointing's memory-saving gradients. When using "speed" gradients, an exception is thrown saying that the operations that were identified as checkpoints lie inside a while loop.

The upshot of this is, unless there are significant changes being made to the gradient-checkpointing code, there is no point in trying this again.

Connection error when accessing the model zoo

Potentially this is related to SSL certification https://stackoverflow.com/a/42334357

As a quick fix: export PYTHONHTTPSVERIFY=0; python net_download.py ...


Clone this wiki locally