How accelerate many times affinetransform, fft and ifft process?

I have many mri(ixi-t2 dataset with.nii.gz format), for each image, what I now do is, create n copies of this image(n is select from(30, 150), for each copy, do random affinetransform, then fft to k-space, for this n k-space, I sample a little from each, then combine sampled k-space, then ifft to spatial image.

The programm is running now, it cost 14 hours to process 80 images(because affinetransform, fft, ifft cost much), there are still 500+ image, so is there a good solution. btw, i use python.

Hello @ydl,

Based on the information you provided, on average it takes about 10min per image. As you repeat the processing n times and n is in (30,150) we really don’t know if you are repeating the processing 30 times or 150 times, this is a significant difference.

Can you share your code (I don’t expect it to be too long) so that we can better identify obvious bottlenecks? Also, you should profile the time it takes for each of the steps. This is readily done in Python, checking the “affine resampling”:

import time

t_prev = time.time()

# SimpleITK affine resampling lines

print(f"{time.time() - t_prev} sec")

@zivy my code is too long about total 200+ lines(most of my code random generate affinetransform parameters), n is random seleced from uniform(30, 150).

Hello @ydl,

Thanks for sharing the information. Can you share the timing profiling information for each of the steps:

  1. using affine transform resampling.
  2. FFT
  3. resampling FFT space and combining.
  4. IFFT

This will help identify the bottleneck.