title: Change entire images slices of NIFTI in Python 3.7
body: <p>I'm actually work on MRI images using Python.
  The image format is the NIFTI format
  I get how to visualise slices on x, y or z axe, but now, I want tu use Sobel filtering on each of them and create a new NIFTI image with those slices.</p>
  
  <p>For that:</p>
  
  <ul>
  <li>I load the main .nii.gz image (img = nib.load(im_path))</li>
  <li>I load again the main .nii.gz image with a new name "img_sobel" (img_sobel = nib.load(im_path))</li>
  <li>Create a loop for each slice</li>
  <li>Sobel filtering the slice</li>
  <li>Replace this slice on the corresponding slice of img_sobel ("img_sobel_data[:, :, sl] == np.hypot(sx, sy)")</li>
  <li>After the loop, save the img_sobel with the name "image_XXX_Sobel"</li>
  </ul>
  
  <p>Using subplot, I see the sobel filtering work on each slice, but it seems the line "img_sobel_data[:, :, sl] == np.hypot(sx, sy)" don't work, why ?</p>
  
  <p>Here's the lopp section :</p>
  
  <pre><code>    # Name the interested data
      img_data = img.get_fdata()
      img_sobel_data = img_sobel.get_fdata()
  
      header = img.header
      nb_img = header.get_data_shape()
      nb_img_h = nb_img[2] #Hauteur
  
      for sl in range(0,nb_img_h):
              slice_h = img_data[:, :, sl]
              #Sobel
              sx = ndimage.sobel(slice_h, axis=0, mode='constant')
              sy = ndimage.sobel(slice_h, axis=1, mode='constant')
              sobel_h = np.hypot(sx, sy)
  
              img_sobel_data[:, :, sl] = sobel_h #Change the image slice to the sobel one
  # Save Sobel:
  nib.save(img_sobel,imSobel_path)
  </code></pre>
  
  <p>What's wrong ? Can't we replace an image slice from another one in Python ? Is there a trick to solve this problem ?</p>
  
  <p>Thank you !</p>
  
  <p>EDIT : OK I get a bit more why I can't do taht so easily : I extracted the slices of the NIFTI image, filtered them, but I wasn't change the NIFTI image itself !!!
  So my question now : How to change the NIFTI image get from img_sobel.get_fdata() ? </p>