omlins / ParallelStencil.jl

Package for writing high-level code for parallel high-performance stencil computations that can be deployed on both GPUs and CPUs
BSD 3-Clause "New" or "Revised" License
312 stars 31 forks source link

3d image application #32

Closed jakubMitura14 closed 3 years ago

jakubMitura14 commented 3 years ago

Hello I am trying to apply this library to 3d medical imaging, as it seems ideal yet I have problems with application of code to my domain. For the beginning I would like to achieve very simple thing just calculate the mean and standard deviation of neighbouring pixels so pseudo code would look like.

# dimensionality increases as input volume holds just intensity , when output volume holds array with mean and standard deviation
function getMeanAndStd ( data ::Array{Int32, 3} ) :: Array{Int32,4}

  out = Array{Int32,4} # preallocating output

   # for example i would use Neumann style stencil and in this naive idea Cartesian index of the center of the stencil
  for ((nsten, cartIndex) in data) 

    flattened = flaten(nsten)
    out[cartIndex] = [ mean(flattened), std(flattened) ] # putting the result in proper place of output

  end
  return out
end

Of course In case of big images i would need to batch the data as I could have a problem in fitting it in GPU memory also as seen from output here further analysis would be in 4d .

I just wanted to ask for some guide How to achieve what I had written above so hopefully I will be able to go on further on my own and later share effects of the work with scientific community.

Thanks for Help!

luraess commented 3 years ago

Thanks @jakubMitura14 for your interest in using ParallelStencil for your 3D image application! Since your question is not an issue with the package but rather an application / usage question, could you please re-post it on Julia Discourse in the most appropriate section as suggested here - maybe in Modelling & Simulations topic ? As such, other folks can also beneficial from the discussion. I prepared a short code I can then share with you that illustrate how to perform your calculations both on CPU or GPU using ParallelStencil.

jakubMitura14 commented 3 years ago

Thanks @jakubMitura14 for your interest in using ParallelStencil for your 3D image application! Since your question is not an issue with the package but rather an application / usage question, could you please re-post it on Julia Discourse in the most appropriate section as suggested here - maybe in Modelling & Simulations topic ? As such, other folks can also beneficial from the discussion. I prepared a short code I can then share with you that illustrate how to perform your calculations both on CPU or GPU using ParallelStencil.

Thank You!!! I did as suggested ( https://discourse.julialang.org/t/3d-medical-app-stencil/64019?u=jakub_mitura ), one more time thank you for your time invested in creating this package and for such fast response to my inquiry - I can't wait to apply the snippet that you mentioned to my domain

luraess commented 3 years ago

Thanks for having posted your question on Discourse. I close this issue, redirecting the discussion on Discourse https://discourse.julialang.org/t/3d-medical-app-stencil/64019