Git Product home page Git Product logo

medsynthesis's Introduction

medSynthesis with TensorFlow (we also provide an improved version in pytorch, you can access it at https://github.com/ginobilinie/medSynthesisV1. Since the pytorch version is recently updated, all the APIs are to the latest and the network is more advanced, I suggest your use the pytorch version.)

This project is for medical image synthesis with generative adversarial networks (GAN), such as, synthesize CT from MRI, 7T from 3T, high does PET from low dose PET.

Currently, we have uploaded a 2D/3D GAN in this repository (2D is in the root folder, and 3D version is in the folder of '3dversion'). Detailed information can be found in our paper:

Medical Image Synthesis with Context-Aware Generative Adversarial Networks

If it is helpful for you, please cite our paper:

@inproceedings{nie2017medical, title={Medical image synthesis with context-aware generative adversarial networks}, author={Nie, Dong and Trullo, Roger and Lian, Jun and Petitjean, Caroline and Ruan, Su and Wang, Qian and Shen, Dinggang}, booktitle={International Conference on Medical Image Computing and Computer-Assisted Intervention}, pages={417--425}, year={2017}, organization={Springer} }

How to run the tensorflow code

The main entrance for the code is main.py

I suppose you have installed:
     tensorflow (>=0.12.1)
     simpleITK
     numpy

Steps to run the code (since the code is implemented as early as 2016, part of the codes are deprecated, you can refer to our pytorch version for new implementations):

  1. use readMedImg4CaffeCropNie4SingleS.py to extract patches (as limited annotated data can be acquired in medical image fields, we usually use patch as the training unit), and save as hdf5 format.
  2. modify the g_model.py if you want to do some changes to the architecture of the generator
  3. modify the d_model.py if you want to do some changes to the architecture of the discriminator
  4. check the loss function in the loss_functions.py.
  5. set up the hyper-parameters in the main.py
  6. run the code: python main.py

Dataset

BTW, you can download a real medical image synthesis dataset for reconstructing standard-dose PET from low-dose PET via this link: https://www.aapm.org/GrandChallenge/LowDoseCT/

Also, there are some MRI synthesis datasets available: http://brain-development.org/ixi-dataset/

Cite

@inproceedings{nie2017medical,
  title={Medical image synthesis with context-aware generative adversarial networks},
  author={Nie, Dong and Trullo, Roger and Lian, Jun and Petitjean, Caroline and Ruan, Su and Wang, Qian and Shen, Dinggang},
  booktitle={International Conference on Medical Image Computing and Computer-Assisted Intervention},
  pages={417--425},
  year={2017},
  organization={Springer}
}
@article{nie2018medical,
  title={Medical Image Synthesis with Deep Convolutional Adversarial Networks},
  author={Nie, Dong and Trullo, Roger and Lian, Jun and Wang, Li and Petitjean, Caroline and Ruan, Su and Wang, Qian and Shen, Dinggang},
  journal={IEEE Transactions on Biomedical Engineering},
  year={2018},
  publisher={IEEE}
}

License

medSynthesis is released under the MIT License (refer to the LICENSE file for details).

medsynthesis's People

Contributors

ginobilinie avatar riyazpanjwani avatar rogertrullo 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

medsynthesis's Issues

ValueError: Variable d_conv_dis_1_a/w/Adam/ does not exist

System Information:

  • Python Version: 2.7.12
  • OS: Ubuntu 16.04 x64, GPU: Nvidia GeForce 940 MX
  • TensorFlow Version: 1.4.0

Problem
Following is the traceback obtained on running python main.py

Traceback:

Traceback (most recent call last):
  File "main.py", line 51, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 48, in main
    lr_step=FLAGS.lr_step,lam_lp=FLAGS.lam_lp, lam_gdl=FLAGS.lam_gdl, lam_adv=FLAGS.lam_adv, alpha=FLAGS.alpha)
  File "/home/aryan/Downloads/medSynthesis/g_model.py", line 58, in __init__
    self.build_model()
  File "/home/aryan/Downloads/medSynthesis/g_model.py", line 79, in build_model
    .minimize(self.d_loss, var_list=self.d_vars)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/optimizer.py", line 353, in minimize
    name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/optimizer.py", line 474, in apply_gradients
    self._create_slots([_get_variable_for(v) for v in var_list])
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/adam.py", line 136, in _create_slots
    self._zeros_slot(v, "m", self._name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/optimizer.py", line 796, in _zeros_slot
    named_slots[_var_key(var)] = slot_creator.create_zeros_slot(var, op_name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/slot_creator.py", line 174, in create_zeros_slot
    colocate_with_primary=colocate_with_primary)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/slot_creator.py", line 148, in create_slot_with_initializer
    dtype)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/slot_creator.py", line 67, in _create_slot_var
    validate_shape=validate_shape)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 1203, in get_variable
    constraint=constraint)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 1092, in get_variable
    constraint=constraint)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 425, in get_variable
    constraint=constraint)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 394, in _true_getter
    use_resource=use_resource, constraint=constraint)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 760, in _get_single_variable
    "reuse=tf.AUTO_REUSE in VarScope?" % name)
ValueError: Variable d_conv_dis_1_a/w/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=tf.AUTO_REUSE in VarScope?

Dataset

Hi,I have read your article, the method proposed is very good, but there are a lot of problems when running the code, I hope you can help me, I have got access to the ADNI database, but I don't know how to download the required data set, can you share the data set you use with me?

where is your d_scale_model?

we could not find the d_scale_model in fifth line in your d_model.py through your medsynthesis, could you give me some details? thanks!

package

I‘m sorry to bother you. I want to reproduce your code.Howere,in the package I downloaded, it says that d_scale_model cannot be found. In this file: from d_scale_model import DScaleModel.Is there something wrong here?

index out of bounds error

I'm using your code for 3T to 7T conversion.
When i run the first program readMedImg4CaffeCropNie4SingleS.py to extract patches.
I'm getting this error
"IndexError: index 40000 is out of bounds for axis 0 with size 40000"?
Can you please help me in solving this.

About aligned MRI and CT image.

HI,

I did not find CT images in ADNI dataset (DTI, MRI, PET, fMRI. but not CT), how can i get the aligned MRI and CT images.

In http://adni.loni.usc.edu/methods/documents/

"
1)The brain dataset was acquired from 16 subjects with both MRI and CT scans in the Alzheimer’s Disease Neuroimaging Initiative (ADNI) database (see www.adniinfo.org for details). The MR images were acquired using a Siemens Triotim scanner, with the voxel size 1.2 × 1.2 ×1mm3 , TE 2.95 ms, TR 2300 ms, and flip angle 9◦. The CT images, with the voxel size 0.59 × 0.59 × 3 mm3 , were acquired on a Siemens Somatom scanner. A typical example of preprocessed CT and MR images is given in Fig. 1.

  1. Our pelvic dataset consists of 22 subjects, each with MR and CT images. The spacings of CT and MR images are1.172×1.172×1mm3 and1×1×1mm3,respectively. In the training stage, we rigidly align the CT to MRI with FLIRT for each subject [49]. "

Thanks.

FCN generator

When I run the 3D FCN model, I get an error:
shape output G (?, 24, 24, 24, 1)
ValueError: Cannot feed value of shape (20, 1, 32, 32, 1, 5) for Tensor 'Placeholder:0', which has shape '(?, 32, 32, 32, 1)'

trouble to understand latent space

Hi all,

Please, I am struggling to understand how the latent space is used in your code.
I would like to know how MRI patches are related to the latent space to synthesize the pseudo-CT. If one can consider that the distribution used to initialize the filters can be considered as the latent space.

Thank you in advance for your understanding.

Data processing

I am very interested in your work, I now have some doubts:
(1) In your paper, the image size is 153X193X50, and The image size I used is 240X240X155, will the image size affect the result?
(2) In your paper, the MR size is 32X32X32, the CT size is 16X16X16, the image MR size obtained in the code is 64X64X64, the CT size is 48X48X48, but your note is THE MR size is 32X32X32, the CT size is 24X24X24, What dimension size should I take?

What to do with the data

I have downloaded the brainData in NIFTI format from IXI and put them in /raid/dongnie/brainData, but it reports an error:
FileNotFoundError: [WinError 3] The system could not find the specified path: '/raid/dongnie/brainData'
Do I need to process these data further?

Dataset problems

Thank you very much for your excellent work. Now I plan to use MRI to transform CT. Do I need labeled MRI and CT data as input items to run the code? Looking forward to your reply.

About GDL loss

Hello, first of all thank you for sharing. This is a great job. About GDL loss in 3dganversion/loss_functions/gdl3d_loss, If the shape obtained by the generator is (1,128,128,128,1), how can it become the gen_frames, gt_frames needed in the code. Besides, what is the value of alpha?
Best wishes!
Thank you!

3T to 7T model

Hi, I just looked through your paper. I'm quite interested in the 3T to 7T part. It seems that the code published here is intended for MR-to-CT. Are you using the same code for 3T-to-7T training? Or do you have another version that you can share for the 3T-to-7T part for your paper?

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.