imatge-upc / 3D-GAN-superresolution

3D super-resolution using Generative Adversarial Networks
164 stars 46 forks source link

skull-stripping processing #5

Open joellerena opened 5 years ago

joellerena commented 5 years ago

Referencing from: ... to 'T1_brain_extractedBrainExtractionMask.nii.gz' file. This file was created taking the original images from ADNI and performing a skull-stripping processing of them. We use the nibabel library to load the images. https://github.com/imatge-upc/3D-GAN-superresolution I ask if a process was considered as indicated: http://fsl.fmrib.ox.ac.uk/fslcourse/lectures/practicals/intro2/index.html, .... try -f 0.3 -g 0.2 Thank you for your answer.

joellerena commented 5 years ago

The steps to obtain 224x224x152: Skull stripping is performed in all volumes and part of the background is removed. Final volumes have dimensions 224x224x152

Dragomir2020 commented 5 years ago

I was wondering if you have any info on the number and type of GPU. Also, it would be useful to know how much GPU and CPU memory this code needs. Thanks.

Yaqiongchai commented 5 years ago

It is really great work! @sanchezirina Could you possibly upload the models you trained? Or something in the checkpoints_restore_dir would be very appreciated. It keeps complaining " in restore raise ValueError("Can't load save_path when it is None.")"

joellerena commented 5 years ago

Thanks for your interest in the subject. I'm in a quagmire, I try to play https://github.com/imatge-upc/3D-GAN-superresolution, I get an error. I will try again with new images of ADNI with T1 and choosing sizes of 256, 256 and 184 and tesla of 1.5 I understand that the project runs on CPU, I use a ncore I9 I share the error so you can give me an idea, on page 6 of http://bit.ly/3DganRe. I share the structure they use http://bit.ly/3Dgan I have written to the authors but they have not answered the query, I will keep waiting.

Traceback (most recent call last): File "model.py", line 502, in <module> img_height=128, img_depth=92, batch_size=1, restore=args.restore) File "model.py", line 329, in train errd, _ = session.run([d_loss, d_optim], {t_target_image: xt, t_input_gen: xgenin}) tensorflow.python.framework.errors_impl.InvalidArgumentError: Conv3DBackpropInput: Number of plans of out_backprop does not match computed: current = 0, computed = 64 [[Node: SRGAN_g / conv1-ub-subpixelnn / 1 / conv3d_transpose = Conv3DBackpropInputV2 [T = DT_FLOAT, data_format = "NDHWC", padding = "SAME", strides = [1, 2, 2, 2, 1], _device = "/ job: localhost / replica: 0 / task: 0 / device: CPU: 0"] (SRGAN_g / conv1-ub-subpixelnn / 1 / conv3d_transpose / output_shape, SRGAN_g / conv1-ub-subpixelnn / 1 / W_deconv3d / read, SRGAN_g / add-conv2)]]

Caused by op u'SRGAN_g / conv1-ub-subpixelnn / 1 / conv3d_transpose ', defined at:   File "model.py", line 502, in <module>     img_height = 128, img_depth = 92, batch_size = 1, restore = args.restore)   File "model.py", line 225, in train     feature_size = feature_size, is_train = True, reuse = False)   File "model.py", line 132, in generator     padding = 'SAME', W_init = w_init_subpixel1_last, name = 'conv1-ub-subpixelnn / 1') #cause error

I have looked for those errors and in forums they indicate to me that it is probable that the images of entrance are those that provoke them. I will download ADNI images again and I will comment on them.

The article is very good in your reading. I appreciate your comments.

joellerena commented 5 years ago

I have downloaded new ADNI images now with Field Field Strength (tesla) = 1.5 and Matrix Z = 184 With these new images I understand that the size of the image complies with what is indicated in the code for the generation of patches line 118 onwards -dataset.py-

The new error is now in the depth. paddepthl and paddepthr

[TL] got 33: SRGAN_d / dense2 / b: 0 (1,) /home/terranostra/3D-GAN-superresolution-master/dataset.py:83: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future   self.depth_patch + self.margin, 1]) Traceback (most recent call last):   File "model.py", line 502, in <module>     img_height = 128, img_depth = 92, batch_size = 1, restore = args.restore)   File "model.py", line 306, in train     xm_total = traindataset.mask (i)   File "/home/terranostra/3D-GAN-superresolution-master/dataset.py", line 57, in mask     'constant', constant_values ​​= 0)   File "/home/terranostra/anaconda2/lib/python2.7/site-packages/numpy/lib/arraypad.py", line 1318, in pad     pad_width = _validate_lengths (narray, pad_width)   File "/home/terranostra/anaconda2/lib/python2.7/site-packages/numpy/lib/arraypad.py", line 1109, in _validate_lengths     raise ValueError (fmt% (number_elements,)) ValueError: [(36, 36), (0, 0), (-36, -36)] can not contain negative values.

joellerena commented 5 years ago

[TL] got 33: SRGAN_d/dense2/b:0 (1,) <class 'nibabel.nifti1.Nifti1Image'> data shape (184, 256, 256) ... dim : [ 3 184 256 256 1 1 1 1] ....

Traceback (most recent call last):
  File "model.py", line 502, in <module>
    img_height=128, img_depth=92, batch_size=1, restore=args.restore)
  File "model.py", line 305, in train
    xt_total = traindataset.patches_true(i)
  File "/home/terranostra/3D-GAN-superresolution-master/dataset.py", line 90, in patches_true
    subjects_true = self.data_true(iteration)
  File "/home/terranostra/3D-GAN-superresolution-master/dataset.py", line 154, in data_true
    subjects[i] = data_padded[16:240, 16:240, 16:168]  # remove background
ValueError: could not broadcast input array from shape (168,224,152) into shape (224,224,152)
terranostra@terranostra:~/3D-GAN-superresolution-master$ 

Finding 256-256-184 images was better, showed an error of (36,36), (0,0), (- 36, -36) with the negative numbers, it was solved with changing shape [0], with the shape [2] that are depth, vertical and horizontal in data shape (184, 256, 256) Now an error is shown when changing the shape, I must find the code that affects that change. ValueError: could not broadcast input array from shape (168,224,152) into shape (224,224,152)

http://bit.ly/3DganNew All the work: http://bit.ly/3Dgan

joellerena commented 5 years ago

I get the following error with nn:


Traceback (most recent call last):
  File "model.py", line 505, in <module>
    img_height=128, img_depth=92, batch_size=1, restore=args.restore)
  File "model.py", line 332, in train
    errd, _ = session.run([d_loss, d_optim], {t_target_image: xt, t_input_gen: xgenin})
  File "/home/terranostra/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 889, in run
    run_metadata_ptr)
  File "/home/terranostra/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1120, in _run
    feed_dict_tensor, options, run_metadata)
  File "/home/terranostra/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1317, in _do_run
    options, run_metadata)
  File "/home/terranostra/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1336, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [0,1] vs. [2,1]
     [[Node: sub_1 = Sub[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](SRGAN_d_1/dense2/add, random_uniform_1)]]

Caused by op u'sub_1', defined at:
  File "model.py", line 505, in <module>
    img_height=128, img_depth=92, batch_size=1, restore=args.restore)
  File "model.py", line 251, in train
    d_loss_fake = tf.reduce_mean(tf.square(disc_out_fake - smooth_gan_labels(y_gan_fake)),
  File "/home/terranostra/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 894, in binary_op_wrapper
    return func(x, y, name=name)
  File "/home/terranostra/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 4636, in _sub
    "Sub", x=x, y=y, name=name)
  File "/home/terranostra/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/terranostra/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2956, in create_op
    op_def=op_def)
  File "/home/terranostra/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1470, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Incompatible shapes: [0,1] vs. [2,1]
     [[Node: sub_1 = Sub[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](SRGAN_d_1/dense2/add, random_uniform_1)]]
joellerena commented 5 years ago

It works, thanks.

Figure_1

Figure_2