From simon.rit at creatis.insa-lyon.fr Mon Jul 1 03:49:53 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Mon, 1 Jul 2019 09:49:53 +0200 Subject: [Rtk-users] Use RTK library for fan beam CT In-Reply-To: References: Message-ID: Hi, RTK only works in 3D. Still, you can describe this in 3D. You must set RadiusCylindricalDetector. See the geometry doc here . Note that only iterative reconstruction currently works with this geometry. Simon On Sun, Jun 30, 2019 at 2:06 PM Ali ghorbanian wrote: > Hi, > How to use RTK library for fan beam CT (cone beam x-ray with curve shape > detector)? > As figure : > [image: image.png] > Best regards > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 56586 bytes Desc: not available URL: From simon.rit at creatis.insa-lyon.fr Tue Jul 2 07:06:17 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Tue, 2 Jul 2019 13:06:17 +0200 Subject: [Rtk-users] Use RTK library for fan beam CT In-Reply-To: References: Message-ID: Currently, you cannot use FBP / FDK reconstruction in RTK with cylindrical detector. You can use iterative reconstruction (SART, conjugate gradient, osem, ...) Simon On Tue, Jul 2, 2019 at 1:02 PM Ali ghorbanian wrote: > Hi, > I set RadiusCylindricalDetector and see > Errore(use CudaFDKConeBeamReconstructionFilter method for Reconstruction) > voxel-based FDK back projector can currently not handle Cylindrical > Detectors. > So I can not use the FDK filter? > Which filter should I use for RadiusCylindricalDetector in RTK? > > Best regards > > On Mon, Jul 1, 2019 at 12:19 PM Simon Rit > wrote: > >> Hi, >> RTK only works in 3D. Still, you can describe this in 3D. You must set >> RadiusCylindricalDetector. See the geometry doc here >> . Note that only iterative >> reconstruction currently works with this geometry. >> Simon >> >> On Sun, Jun 30, 2019 at 2:06 PM Ali ghorbanian >> wrote: >> >>> Hi, >>> How to use RTK library for fan beam CT (cone beam x-ray with curve >>> shape detector)? >>> As figure : >>> [image: image.png] >>> Best regards >>> _______________________________________________ >>> Rtk-users mailing list >>> Rtk-users at public.kitware.com >>> https://public.kitware.com/mailman/listinfo/rtk-users >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 56586 bytes Desc: not available URL: From clem.schmid at gmail.com Tue Jul 2 11:50:49 2019 From: clem.schmid at gmail.com (C S) Date: Tue, 2 Jul 2019 11:50:49 -0400 Subject: [Rtk-users] GPU support of PyPI package Message-ID: Dear RTK users, is there a possibility to get GPU support within RTK from the PyPI package "itk-rtk"? https://pypi.org/project/itk-rtk/ If not, what is the current "best practice" building RTK with GPU and Python bindings? I'm on Ubuntu 18.04 with CUDA 10.0. Thank you very much for your help! Clemens -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.rit at creatis.insa-lyon.fr Tue Jul 2 11:57:29 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Tue, 2 Jul 2019 17:57:29 +0200 Subject: [Rtk-users] GPU support of PyPI package In-Reply-To: References: Message-ID: Hi, No yet! We aim at proposing this soon but it's not ready. The best practice is to build from ITK, turn on Module_RTK, RTK_USE_CUDA and ITK_WRAP_PYTHON. Someone has already requested a proper compilation doc, we'll work on it asap, sorry for the inconvenience. Simon On Tue, Jul 2, 2019 at 5:51 PM C S wrote: > Dear RTK users, > > is there a possibility to get GPU support within RTK from the PyPI package > "itk-rtk"? > https://pypi.org/project/itk-rtk/ > > If not, what is the current "best practice" building RTK with GPU and > Python bindings? I'm on Ubuntu 18.04 with CUDA 10.0. > > > Thank you very much for your help! > Clemens > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clem.schmid at gmail.com Tue Jul 2 17:01:23 2019 From: clem.schmid at gmail.com (C S) Date: Tue, 2 Jul 2019 17:01:23 -0400 Subject: [Rtk-users] GPU support of PyPI package In-Reply-To: References: Message-ID: Hi Simon, thank you very much for your swift answer! If compiling for GPU, I don't need ITK_USE_FFTWD or ITK_USE_FFTWF, right? Would you recommend using ITK_USE_CUFFTW? Best Clemens Am Di., 2. Juli 2019 um 11:56 Uhr schrieb Simon Rit < simon.rit at creatis.insa-lyon.fr>: > Hi, > No yet! We aim at proposing this soon but it's not ready. The best > practice is to build from ITK, turn on Module_RTK, RTK_USE_CUDA and > ITK_WRAP_PYTHON. > Someone has already requested a proper compilation doc, we'll work on it > asap, sorry for the inconvenience. > Simon > > On Tue, Jul 2, 2019 at 5:51 PM C S wrote: > >> Dear RTK users, >> >> is there a possibility to get GPU support within RTK from the PyPI >> package "itk-rtk"? >> https://pypi.org/project/itk-rtk/ >> >> If not, what is the current "best practice" building RTK with GPU and >> Python bindings? I'm on Ubuntu 18.04 with CUDA 10.0. >> >> >> Thank you very much for your help! >> Clemens >> _______________________________________________ >> Rtk-users mailing list >> Rtk-users at public.kitware.com >> https://public.kitware.com/mailman/listinfo/rtk-users >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.rit at creatis.insa-lyon.fr Wed Jul 3 02:13:16 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Wed, 3 Jul 2019 08:13:16 +0200 Subject: [Rtk-users] GPU support of PyPI package In-Reply-To: References: Message-ID: You never need this option except for using ExtractPhaseImageFilter but it makes the CPU version faster. So you don't need it if you only use the GPU version of FDK. I don't know anlything about ITK_USE_CUFFTW, it's a recent option I've never used... Cheers, Simon On Tue, Jul 2, 2019 at 11:01 PM C S wrote: > Hi Simon, > > thank you very much for your swift answer! > > If compiling for GPU, I don't need ITK_USE_FFTWD or ITK_USE_FFTWF, right? > Would you recommend using ITK_USE_CUFFTW? > > > Best > Clemens > > Am Di., 2. Juli 2019 um 11:56 Uhr schrieb Simon Rit < > simon.rit at creatis.insa-lyon.fr>: > >> Hi, >> No yet! We aim at proposing this soon but it's not ready. The best >> practice is to build from ITK, turn on Module_RTK, RTK_USE_CUDA and >> ITK_WRAP_PYTHON. >> Someone has already requested a proper compilation doc, we'll work on it >> asap, sorry for the inconvenience. >> Simon >> >> On Tue, Jul 2, 2019 at 5:51 PM C S wrote: >> >>> Dear RTK users, >>> >>> is there a possibility to get GPU support within RTK from the PyPI >>> package "itk-rtk"? >>> https://pypi.org/project/itk-rtk/ >>> >>> If not, what is the current "best practice" building RTK with GPU and >>> Python bindings? I'm on Ubuntu 18.04 with CUDA 10.0. >>> >>> >>> Thank you very much for your help! >>> Clemens >>> _______________________________________________ >>> Rtk-users mailing list >>> Rtk-users at public.kitware.com >>> https://public.kitware.com/mailman/listinfo/rtk-users >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From clem.schmid at gmail.com Mon Jul 8 16:05:42 2019 From: clem.schmid at gmail.com (C S) Date: Mon, 8 Jul 2019 16:05:42 -0400 Subject: [Rtk-users] Use existing Images when copying from/to GPU Message-ID: Dear RTK users, I'm looking for a way to use exisiting ITK Images (either on GPU or in RAM) when transfering data from/to GPU. That is, not only re-using the Image object, but writing into the memory where its buffer is. Why: As I'm using the Python bindings, I guess this ties in with ITK wrapping the CudaImage type. In https://github.com/SimonRit/RTK/blob/master/utilities/ITKCudaCommon/include/itkCudaImage.h#L32 I read that the memory management is done implicitly and the CudaImage can be used with CPU filters. However when using the bindings, only rtk.BackProjectionImageFilter can be used with CudaImages. The other filters complain about not being wrapped for that type. That is why I want to explicitely transfer the data from/to GPU, but preferably using the exisiting Images and buffers. I can't rely on RTK managing GPU memory implicitly. Thank you very much for your help! Clemens -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.rit at creatis.insa-lyon.fr Mon Jul 8 16:20:50 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Mon, 8 Jul 2019 22:20:50 +0200 Subject: [Rtk-users] Use existing Images when copying from/to GPU In-Reply-To: References: Message-ID: Hi, Conversion from Image to CudaImage is not optimal. The way I'm doing it now is shown in an example in these few lines . I am aware of the problem and discussed it on the ITK forum but I don't have a better solution yet. I'm not sure what you mean by explicitely transferring data from/to GPU but I guess you can always work with itk::Image and do your own CUDA computations in the GenerateData of the ImageFilter if you don't like the CudaImage mechanism. I hope this helps, Simon On Mon, Jul 8, 2019 at 10:06 PM C S wrote: > Dear RTK users, > > I'm looking for a way to use exisiting ITK Images (either on GPU or in > RAM) when transfering data from/to GPU. That is, not only re-using the > Image object, but writing into the memory where its buffer is. > > Why: As I'm using the Python bindings, I guess this ties in with ITK > wrapping the CudaImage type. In > https://github.com/SimonRit/RTK/blob/master/utilities/ITKCudaCommon/include/itkCudaImage.h#L32 I > read that the memory management is done implicitly and the CudaImage can be > used with CPU filters. However when using the bindings, > only rtk.BackProjectionImageFilter can be used with CudaImages. The other > filters complain about not being wrapped for that type. > > That is why I want to explicitely transfer the data from/to GPU, but > preferably using the exisiting Images and buffers. I can't rely on RTK > managing GPU memory implicitly. > > > Thank you very much for your help! > Clemens > > > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clem.schmid at gmail.com Mon Jul 8 16:45:35 2019 From: clem.schmid at gmail.com (C S) Date: Mon, 8 Jul 2019 16:45:35 -0400 Subject: [Rtk-users] Use existing Images when copying from/to GPU In-Reply-To: References: Message-ID: Hi Simon, thank you for your swift reply and suggestions! In fact I'm already using your snippet for cpu->gpu transfer. My main issue is using the existing cpu image when transfering back to cpu, which I have not been able to do. I can use the itk.ImageDuplicator for getting the data into RAM but I haven't found a way to point the itk.ImageDuplicator's *output* to an exisiting Image. It always creates a new Image and allocates new memory AFAIK. Once I can do that the next optimization step would be to also use an exisiting CudaImage (with according buffer) when transfering cpu->gpu, *contrary to your snippet.* For that I have found no way at all so far. To clarify, I do not want to perform my own CUDA computations. Using RTK's CUDA forward/backprojectors is the main feature I want to use from RTK. With *explicit* I mean doing the transfer myself instead of relying on RTK's implicit methods implied in the source code . Best Clemens Am Mo., 8. Juli 2019 um 16:20 Uhr schrieb Simon Rit < simon.rit at creatis.insa-lyon.fr>: > Hi, > Conversion from Image to CudaImage is not optimal. The way I'm doing it > now is shown in an example in these few lines > . > I am aware of the problem and discussed it on the ITK forum > > but I don't have a better solution yet. > I'm not sure what you mean by explicitely transferring data from/to GPU > but I guess you can always work with itk::Image and do your own CUDA > computations in the GenerateData of the ImageFilter if you don't like the > CudaImage mechanism. > I hope this helps, > Simon > > On Mon, Jul 8, 2019 at 10:06 PM C S wrote: > >> Dear RTK users, >> >> I'm looking for a way to use exisiting ITK Images (either on GPU or in >> RAM) when transfering data from/to GPU. That is, not only re-using the >> Image object, but writing into the memory where its buffer is. >> >> Why: As I'm using the Python bindings, I guess this ties in with ITK >> wrapping the CudaImage type. In >> https://github.com/SimonRit/RTK/blob/master/utilities/ITKCudaCommon/include/itkCudaImage.h#L32 I >> read that the memory management is done implicitly and the CudaImage can be >> used with CPU filters. However when using the bindings, >> only rtk.BackProjectionImageFilter can be used with CudaImages. The other >> filters complain about not being wrapped for that type. >> >> That is why I want to explicitely transfer the data from/to GPU, but >> preferably using the exisiting Images and buffers. I can't rely on RTK >> managing GPU memory implicitly. >> >> >> Thank you very much for your help! >> Clemens >> >> >> _______________________________________________ >> Rtk-users mailing list >> Rtk-users at public.kitware.com >> https://public.kitware.com/mailman/listinfo/rtk-users >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.rit at creatis.insa-lyon.fr Mon Jul 8 17:13:05 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Mon, 8 Jul 2019 23:13:05 +0200 Subject: [Rtk-users] Use existing Images when copying from/to GPU In-Reply-To: References: Message-ID: On Mon, Jul 8, 2019 at 10:45 PM C S wrote: > Hi Simon, > > thank you for your swift reply and suggestions! > > In fact I'm already using your snippet > for > cpu->gpu transfer. My main issue is using the existing cpu image when > transfering back to cpu, which I have not been able to do. I can use > the itk.ImageDuplicator for getting the data into RAM but I haven't found a > way to point the itk.ImageDuplicator's *output* to an exisiting Image. It > always creates a new Image and allocates new memory AFAIK. > I'm not sure I understand but have you tried grafting the Image or CudaImage to an existing itk::Image (the Graft function)? > > Once I can do that the next optimization step would be to also use an > exisiting CudaImage (with according buffer) when transfering cpu->gpu, *contrary > to your snippet.* For that I have found no way at all so far. > Again, I'm not sure I understand but you should be able to graft a CudaImage to another CudaImage. > To clarify, I do not want to perform my own CUDA computations. Using RTK's > CUDA forward/backprojectors is the main feature I want to use from RTK. > With *explicit* I mean doing the transfer myself instead of relying on > RTK's implicit methods implied in the source code > > . > You can always ask explicit transfers by calling the functions of the data manager (accessible via CudaImage::GetCudaDataManager()) > > > Best > Clemens > > Am Mo., 8. Juli 2019 um 16:20 Uhr schrieb Simon Rit < > simon.rit at creatis.insa-lyon.fr>: > >> Hi, >> Conversion from Image to CudaImage is not optimal. The way I'm doing it >> now is shown in an example in these few lines >> . >> I am aware of the problem and discussed it on the ITK forum >> >> but I don't have a better solution yet. >> I'm not sure what you mean by explicitely transferring data from/to GPU >> but I guess you can always work with itk::Image and do your own CUDA >> computations in the GenerateData of the ImageFilter if you don't like the >> CudaImage mechanism. >> I hope this helps, >> Simon >> >> On Mon, Jul 8, 2019 at 10:06 PM C S wrote: >> >>> Dear RTK users, >>> >>> I'm looking for a way to use exisiting ITK Images (either on GPU or in >>> RAM) when transfering data from/to GPU. That is, not only re-using the >>> Image object, but writing into the memory where its buffer is. >>> >>> Why: As I'm using the Python bindings, I guess this ties in with ITK >>> wrapping the CudaImage type. In >>> https://github.com/SimonRit/RTK/blob/master/utilities/ITKCudaCommon/include/itkCudaImage.h#L32 I >>> read that the memory management is done implicitly and the CudaImage can be >>> used with CPU filters. However when using the bindings, >>> only rtk.BackProjectionImageFilter can be used with CudaImages. The other >>> filters complain about not being wrapped for that type. >>> >>> That is why I want to explicitely transfer the data from/to GPU, but >>> preferably using the exisiting Images and buffers. I can't rely on RTK >>> managing GPU memory implicitly. >>> >>> >>> Thank you very much for your help! >>> Clemens >>> >>> >>> _______________________________________________ >>> Rtk-users mailing list >>> Rtk-users at public.kitware.com >>> https://public.kitware.com/mailman/listinfo/rtk-users >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From clem.schmid at gmail.com Mon Jul 8 18:07:30 2019 From: clem.schmid at gmail.com (C S) Date: Mon, 8 Jul 2019 18:07:30 -0400 Subject: [Rtk-users] Use existing Images when copying from/to GPU In-Reply-To: References: Message-ID: Hi Simon, I'm not sure I understand but have you tried grafting the Image or > CudaImage to an existing itk::Image (the Graft function)? > I tried that but when I call itk.GetArrayFromImage(cuda_img) on the grafted image (cpu_img.Graft(cuda_img)) I get the error ```ValueError: PyMemoryView_FromBuffer(): info->buf must not be NULL``` from within ITK (or its Python bindings). > Again, I'm not sure I understand but you should be able to graft a > CudaImage to another CudaImage. > If anything I'd like to graft an Image into a CudaImage. When I try something like `cuda_img.Graft(cpu_img)` I get a TypeError. If this and the Graft'ing above would work (including the array view), that would be exactly my initial wish. > You can always ask explicit transfers by calling the functions of the data > manager (accessible via CudaImage::GetCudaDataManager()) > I assume you mean manager.UpdateCPUBuffer()? When I run that, the CPU image I used to create the GPU image (by this ) is not updated. My scenario is this: I give a numpy array as a volume to be forward projected. I get a ImageView from that array, set origin and spacing of that image and transfer to GPU via your method . For the output projections, I use an ImageView from a numpy.zeros array with according shape, spacing and origin and transfer that to GPU the same way. I then use the CudaForwardProjection filter. Now I'd like to have the projection data on CPU. Unfortunately, none of the suggested methods worked for me other than using an itk.ImageDuplicator on the CudaImage :( Sorry for the lenghty mail. Best Clemens > >> >> Best >> Clemens >> >> Am Mo., 8. Juli 2019 um 16:20 Uhr schrieb Simon Rit < >> simon.rit at creatis.insa-lyon.fr>: >> >>> Hi, >>> Conversion from Image to CudaImage is not optimal. The way I'm doing it >>> now is shown in an example in these few lines >>> . >>> I am aware of the problem and discussed it on the ITK forum >>> >>> but I don't have a better solution yet. >>> I'm not sure what you mean by explicitely transferring data from/to GPU >>> but I guess you can always work with itk::Image and do your own CUDA >>> computations in the GenerateData of the ImageFilter if you don't like the >>> CudaImage mechanism. >>> I hope this helps, >>> Simon >>> >>> On Mon, Jul 8, 2019 at 10:06 PM C S wrote: >>> >>>> Dear RTK users, >>>> >>>> I'm looking for a way to use exisiting ITK Images (either on GPU or in >>>> RAM) when transfering data from/to GPU. That is, not only re-using the >>>> Image object, but writing into the memory where its buffer is. >>>> >>>> Why: As I'm using the Python bindings, I guess this ties in with ITK >>>> wrapping the CudaImage type. In >>>> https://github.com/SimonRit/RTK/blob/master/utilities/ITKCudaCommon/include/itkCudaImage.h#L32 I >>>> read that the memory management is done implicitly and the CudaImage can be >>>> used with CPU filters. However when using the bindings, >>>> only rtk.BackProjectionImageFilter can be used with CudaImages. The other >>>> filters complain about not being wrapped for that type. >>>> >>>> That is why I want to explicitely transfer the data from/to GPU, but >>>> preferably using the exisiting Images and buffers. I can't rely on RTK >>>> managing GPU memory implicitly. >>>> >>>> >>>> Thank you very much for your help! >>>> Clemens >>>> >>>> >>>> _______________________________________________ >>>> Rtk-users mailing list >>>> Rtk-users at public.kitware.com >>>> https://public.kitware.com/mailman/listinfo/rtk-users >>>> >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From e.a.gh72 at gmail.com Tue Jul 9 06:41:28 2019 From: e.a.gh72 at gmail.com (Ali ghorbanian) Date: Tue, 9 Jul 2019 15:11:28 +0430 Subject: [Rtk-users] Fan Beam CT with iterative reconstruction Message-ID: Hi, Do have any code example for RadiusCylindricalDetector (Read projection and reconstruction Fan Beam CT with iterative reconstruction )? [image: unnamed.png] Best regards -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: unnamed.png Type: image/png Size: 63057 bytes Desc: not available URL: From simon.rit at creatis.insa-lyon.fr Tue Jul 9 07:17:11 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Tue, 9 Jul 2019 13:17:11 +0200 Subject: [Rtk-users] Fan Beam CT with iterative reconstruction In-Reply-To: References: Message-ID: Hi, With command lines, you can follow the CG example but add the --rad_cyl option to rtksimulatedgeometry. That should work! Simon On Tue, Jul 9, 2019 at 12:42 PM Ali ghorbanian wrote: > > Hi, > Do have any code example for RadiusCylindricalDetector (Read projection > and reconstruction Fan Beam CT with iterative reconstruction )? > [image: unnamed.png] > > Best regards > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: unnamed.png Type: image/png Size: 63057 bytes Desc: not available URL: From clem.schmid at gmail.com Tue Jul 9 12:23:55 2019 From: clem.schmid at gmail.com (C S) Date: Tue, 9 Jul 2019 12:23:55 -0400 Subject: [Rtk-users] Use existing Images when copying from/to GPU In-Reply-To: References: Message-ID: Hi Simon, I think I understood the issue. *Problem:* The CPUBufferPointer of the CudaImage gets altered after calling .Update() on the backprojection/forwardprojection filter. Because of that, the existing numpy array (I created the CPU and GPU images from) does not get changed from the filter. *Solution:* Obtain the CudaDataManager of the CudaImage *before *applying the back-/forwardprojection filter, apply the filter and .Update(), set cpu pointer and update buffer via manager.SetCPUBufferPointer(cpu_img.GetBufferPointer()) manager.UpdateCPUBuffer() The data from the cuda_img is correctly written in-place into the numpy array I constructed the cpu_img from. I don't know the underlying problem and cause why the CPUBuffer gets mangled, but this method achieves what I need. Thank you very much for your advice! Best Clemens Am Mo., 8. Juli 2019 um 18:07 Uhr schrieb C S : > Hi Simon, > > I'm not sure I understand but have you tried grafting the Image or >> CudaImage to an existing itk::Image (the Graft function)? >> > I tried that but when I call itk.GetArrayFromImage(cuda_img) on the > grafted image (cpu_img.Graft(cuda_img)) I get the error ```ValueError: > PyMemoryView_FromBuffer(): info->buf must not be NULL``` from within ITK > (or its Python bindings). > > >> Again, I'm not sure I understand but you should be able to graft a >> CudaImage to another CudaImage. >> > If anything I'd like to graft an Image into a CudaImage. When I try > something like `cuda_img.Graft(cpu_img)` I get a TypeError. If this and > the Graft'ing above would work (including the array view), that would be > exactly my initial wish. > > >> You can always ask explicit transfers by calling the functions of the >> data manager (accessible via CudaImage::GetCudaDataManager()) >> > I assume you mean manager.UpdateCPUBuffer()? When I run that, the CPU > image I used to create the GPU image (by this > ) > is not updated. > > My scenario is this: I give a numpy array as a volume to be forward > projected. I get a ImageView from that array, set origin and spacing of > that image and transfer to GPU via your method > . > For the output projections, I use an ImageView from a numpy.zeros array > with according shape, spacing and origin and transfer that to GPU the same > way. I then use the CudaForwardProjection filter. Now I'd like to have the > projection data on CPU. Unfortunately, none of the suggested methods worked > for me other than using an itk.ImageDuplicator on the CudaImage :( > > Sorry for the lenghty mail. > > Best > Clemens > > >> > >>> >>> Best >>> Clemens >>> >>> Am Mo., 8. Juli 2019 um 16:20 Uhr schrieb Simon Rit < >>> simon.rit at creatis.insa-lyon.fr>: >>> >>>> Hi, >>>> Conversion from Image to CudaImage is not optimal. The way I'm doing it >>>> now is shown in an example in these few lines >>>> . >>>> I am aware of the problem and discussed it on the ITK forum >>>> >>>> but I don't have a better solution yet. >>>> I'm not sure what you mean by explicitely transferring data from/to GPU >>>> but I guess you can always work with itk::Image and do your own CUDA >>>> computations in the GenerateData of the ImageFilter if you don't like the >>>> CudaImage mechanism. >>>> I hope this helps, >>>> Simon >>>> >>>> On Mon, Jul 8, 2019 at 10:06 PM C S wrote: >>>> >>>>> Dear RTK users, >>>>> >>>>> I'm looking for a way to use exisiting ITK Images (either on GPU or in >>>>> RAM) when transfering data from/to GPU. That is, not only re-using the >>>>> Image object, but writing into the memory where its buffer is. >>>>> >>>>> Why: As I'm using the Python bindings, I guess this ties in with ITK >>>>> wrapping the CudaImage type. In >>>>> https://github.com/SimonRit/RTK/blob/master/utilities/ITKCudaCommon/include/itkCudaImage.h#L32 I >>>>> read that the memory management is done implicitly and the CudaImage can be >>>>> used with CPU filters. However when using the bindings, >>>>> only rtk.BackProjectionImageFilter can be used with CudaImages. The other >>>>> filters complain about not being wrapped for that type. >>>>> >>>>> That is why I want to explicitely transfer the data from/to GPU, but >>>>> preferably using the exisiting Images and buffers. I can't rely on RTK >>>>> managing GPU memory implicitly. >>>>> >>>>> >>>>> Thank you very much for your help! >>>>> Clemens >>>>> >>>>> >>>>> _______________________________________________ >>>>> Rtk-users mailing list >>>>> Rtk-users at public.kitware.com >>>>> https://public.kitware.com/mailman/listinfo/rtk-users >>>>> >>>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From e.a.gh72 at gmail.com Wed Jul 10 01:15:20 2019 From: e.a.gh72 at gmail.com (Ali ghorbanian) Date: Wed, 10 Jul 2019 09:45:20 +0430 Subject: [Rtk-users] RadiusCylindricalDetector parameter Message-ID: Hi, [image: unnamed.png] The RadiusCylindricalDetector parameter is the distance between two points ? Best regards -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: unnamed.png Type: image/png Size: 63057 bytes Desc: not available URL: From simon.rit at creatis.insa-lyon.fr Wed Jul 10 01:26:05 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Wed, 10 Jul 2019 07:26:05 +0200 Subject: [Rtk-users] RadiusCylindricalDetector parameter In-Reply-To: References: Message-ID: Hi, It's the radius of the cylinder, see doc . Simon On Wed, Jul 10, 2019 at 7:15 AM Ali ghorbanian wrote: > Hi, > > [image: unnamed.png] > The RadiusCylindricalDetector parameter > is the > distance > between > two > points ? > Best regards > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: unnamed.png Type: image/png Size: 63057 bytes Desc: not available URL: From e.a.gh72 at gmail.com Sat Jul 13 02:00:29 2019 From: e.a.gh72 at gmail.com (Ali ghorbanian) Date: Sat, 13 Jul 2019 10:30:29 +0430 Subject: [Rtk-users] ConjugateGradientConeBeamReconstructionFilter Message-ID: Hi, I read the projections of a fan Beam CT by below syntax: using ReaderType = itk::ImageSeriesReader< OutputImageType >; ReaderType::Pointer reader = ReaderType::New(); const unsigned int first = std::stoi("10000"); const unsigned int last = std::stoi("10403"); using NameGeneratorType = itk::NumericSeriesFileNames; NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New(); nameGenerator->SetSeriesFormat("F:/Data Aqu/98.04.17/Tiff-1/%04d.tiff"); nameGenerator->SetStartIndex(first); nameGenerator->SetEndIndex(last); nameGenerator->SetIncrementIndex(1); reader->SetImageIO(itk::TIFFImageIO::New()); reader->SetFileNames(nameGenerator->GetFileNames()); How to set uniformWeightsSource 's parameter in ConjugateGradientConeBeamReconstructionFilter ? typedef rtk::ConjugateGradientConeBeamReconstructionFilter< OutputImageType > ConjugateGradientType; ConjugateGradientType::Pointer conjugategradient = ConjugateGradientType::New(); conjugategradient->SetInput(tomographySource->GetOutput()); conjugategradient->SetInput(1, reader->GetOutput()); conjugategradient->SetInput(2, *uniformWeightsSource*->GetOutput()); conjugategradient->SetGeometry(geometry); conjugategradient->SetNumberOfIterations(1); conjugategradient->SetDisableDisplacedDetectorFilter(true); conjugategradient->SetGamma(1); Best regards ?? -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.rit at creatis.insa-lyon.fr Mon Jul 15 01:28:27 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Mon, 15 Jul 2019 07:28:27 +0200 Subject: [Rtk-users] ConjugateGradientConeBeamReconstructionFilter In-Reply-To: References: Message-ID: Hi, The conjugate gradient algorithm solves weighted least squares. If you want to use unweighted least squares, simply pass an image filled with ones which has the same size as the projections. Simon On Sat, Jul 13, 2019 at 8:01 AM Ali ghorbanian wrote: > Hi, > I read the projections of a fan Beam CT by below syntax: > > using ReaderType = itk::ImageSeriesReader< OutputImageType >; > ReaderType::Pointer reader = ReaderType::New(); > const unsigned int first = std::stoi("10000"); > const unsigned int last = std::stoi("10403"); > using NameGeneratorType = itk::NumericSeriesFileNames; > NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New(); > nameGenerator->SetSeriesFormat("F:/Data Aqu/98.04.17/Tiff-1/%04d.tiff"); > nameGenerator->SetStartIndex(first); > nameGenerator->SetEndIndex(last); > nameGenerator->SetIncrementIndex(1); > reader->SetImageIO(itk::TIFFImageIO::New()); > reader->SetFileNames(nameGenerator->GetFileNames()); > > How to set > uniformWeightsSource > 's parameter > in > ConjugateGradientConeBeamReconstructionFilter > ? > > > typedef rtk::ConjugateGradientConeBeamReconstructionFilter< > OutputImageType > ConjugateGradientType; > ConjugateGradientType::Pointer conjugategradient = > ConjugateGradientType::New(); > conjugategradient->SetInput(tomographySource->GetOutput()); > conjugategradient->SetInput(1, reader->GetOutput()); > conjugategradient->SetInput(2, *uniformWeightsSource*->GetOutput()); > conjugategradient->SetGeometry(geometry); > conjugategradient->SetNumberOfIterations(1); > conjugategradient->SetDisableDisplacedDetectorFilter(true); > conjugategradient->SetGamma(1); > > Best regards > ?? > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clem.schmid at gmail.com Tue Jul 16 10:20:55 2019 From: clem.schmid at gmail.com (C S) Date: Tue, 16 Jul 2019 10:20:55 -0400 Subject: [Rtk-users] Use existing Images when copying from/to GPU In-Reply-To: References: Message-ID: Hey Maik, here is some example code for a forwardprojection on GPU from a numpy array volume. https://gist.github.com/clemisch/9ec752430b2eb65d9840d69fc8c058bb You may write a projector class around that to save the proj_spacing, img_spacing, ... parameters and projector objects. Maybe even re-use the GPU images. I constructed this snipped from my framework but did not test it by itself; there might be bugs. Let me know if that helps you. Best Clemens Am Di., 16. Juli 2019 um 08:18 Uhr schrieb imt : > Hej Clemens, > > I was following your conversation with Simon. I am quite interested in the > problem. Do you have some simple example source code of your solution? That > would be really helpful. > > Thank you in advance > Maik > On 9 Jul 2019, 18:24 +0200, C S , wrote: > > Hi Simon, > > I think I understood the issue. > > *Problem:* The CPUBufferPointer of the CudaImage gets altered after > calling .Update() on the backprojection/forwardprojection filter. Because > of that, the existing numpy array (I created the CPU and GPU images from) > does not get changed from the filter. > *Solution:* Obtain the CudaDataManager of the CudaImage *before* applying > the back-/forwardprojection filter, apply the filter and .Update(), set cpu > pointer and update buffer via > > manager.SetCPUBufferPointer(cpu_img.GetBufferPointer()) > manager.UpdateCPUBuffer() > > The data from the cuda_img is correctly written in-place into the numpy > array I constructed the cpu_img from. > > I don't know the underlying problem and cause why the CPUBuffer gets > mangled, but this method achieves what I need. Thank you very much for your > advice! > > > Best > Clemens > > Am Mo., 8. Juli 2019 um 18:07 Uhr schrieb C S : > > Hi Simon, > > I'm not sure I understand but have you tried grafting the Image or > CudaImage to an existing itk::Image (the Graft function)? > > I tried that but when I call itk.GetArrayFromImage(cuda_img) on the > grafted image (cpu_img.Graft(cuda_img)) I get the error ```ValueError: > PyMemoryView_FromBuffer(): info->buf must not be NULL``` from within ITK > (or its Python bindings). > > > Again, I'm not sure I understand but you should be able to graft a > CudaImage to another CudaImage. > > If anything I'd like to graft an Image into a CudaImage. When I try > something like `cuda_img.Graft(cpu_img)` I get a TypeError. If this and > the Graft'ing above would work (including the array view), that would be > exactly my initial wish. > > > You can always ask explicit transfers by calling the functions of the data > manager (accessible via CudaImage::GetCudaDataManager()) > > I assume you mean manager.UpdateCPUBuffer()? When I run that, the CPU > image I used to create the GPU image (by this > ) > is not updated. > > My scenario is this: I give a numpy array as a volume to be forward > projected. I get a ImageView from that array, set origin and spacing of > that image and transfer to GPU via your method > . > For the output projections, I use an ImageView from a numpy.zeros array > with according shape, spacing and origin and transfer that to GPU the same > way. I then use the CudaForwardProjection filter. Now I'd like to have the > projection data on CPU. Unfortunately, none of the suggested methods worked > for me other than using an itk.ImageDuplicator on the CudaImage :( > > Sorry for the lenghty mail. > > Best > Clemens > > > > > > Best > Clemens > > Am Mo., 8. Juli 2019 um 16:20 Uhr schrieb Simon Rit < > simon.rit at creatis.insa-lyon.fr>: > > Hi, > Conversion from Image to CudaImage is not optimal. The way I'm doing it > now is shown in an example in these few lines > . > I am aware of the problem and discussed it on the ITK forum > > but I don't have a better solution yet. > I'm not sure what you mean by explicitely transferring data from/to GPU > but I guess you can always work with itk::Image and do your own CUDA > computations in the GenerateData of the ImageFilter if you don't like the > CudaImage mechanism. > I hope this helps, > Simon > > On Mon, Jul 8, 2019 at 10:06 PM C S wrote: > > Dear RTK users, > > I'm looking for a way to use exisiting ITK Images (either on GPU or in > RAM) when transfering data from/to GPU. That is, not only re-using the > Image object, but writing into the memory where its buffer is. > > Why: As I'm using the Python bindings, I guess this ties in with ITK > wrapping the CudaImage type. In > https://github.com/SimonRit/RTK/blob/master/utilities/ITKCudaCommon/include/itkCudaImage.h#L32 I > read that the memory management is done implicitly and the CudaImage can be > used with CPU filters. However when using the bindings, > only rtk.BackProjectionImageFilter can be used with CudaImages. The other > filters complain about not being wrapped for that type. > > That is why I want to explicitely transfer the data from/to GPU, but > preferably using the exisiting Images and buffers. I can't rely on RTK > managing GPU memory implicitly. > > > Thank you very much for your help! > Clemens > > > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andyzhenghan at gmail.com Wed Jul 24 10:56:45 2019 From: andyzhenghan at gmail.com (=?UTF-8?B?6YOR54Ca?=) Date: Wed, 24 Jul 2019 10:56:45 -0400 Subject: [Rtk-users] RTKConfig.cmake Message-ID: Hello, I have build the RTK.sln on Visual Studio 2019, and all 148 project were built successfully. However, I can not find the RTKConfig.cmake in my RTK-bin. Am I missing something? Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.rit at creatis.insa-lyon.fr Thu Jul 25 02:45:21 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Thu, 25 Jul 2019 08:45:21 +0200 Subject: [Rtk-users] WaterPreCorrectionFilter Example - Python In-Reply-To: References: Message-ID: Hi, Apologies for not working on this before. I have updated the wiki page with the code adapted to the new wrapping. Look at the diff between the 2 versions to see the necessary modifications with the new wrappings. I hope this (still) helps, Simon On Wed, Feb 13, 2019 at 8:03 AM Amarnath S wrote: > Hi, > > Thanks for creating the Python version of RTK, and enabling us to get > it via pip. I downloaded it yesterday, and successfully ran the First > Reconstruction Python example. > > Am now trying to convert the WaterPreCorrection example, which was > earlier available using Simple RTK, on this page > http://wiki.openrtk.org/index.php/WaterPreCorrection > > Am using the same dataset for this, as available in the archive > "beam_hardening.tgz" available on the same page. However, am getting an > error while running my code. > > Have created a minimal code in Python, for getting the error, and it is > given here. > > import sys > import itk > from itk import RTK as rtk > import glob > import os > > # Script parameter > dir = "F:\\RTKDir\\output\\" > > # List of filenames > fileNames = [] > for file in os.listdir(dir): > if file.startswith("attenuation") and file.endswith(".mha"): > fileNames.append(dir + file) > > projReader = rtk.ProjectionsReader.New() > projReader.SetFileNames(fileNames) > print("Filenames set") > > waterPre = rtk.WaterPrecorrectionImageFilter.New(); > wpcoeffs = [0, 0, 0, 0, 0, 0, 1] > print("Water Pre defined") > > waterPre.SetCoefficients(wpcoeffs) > waterPre.SetInput(projReader.GetOutput()) > print("Gives error on the above line - Expecting argument of type > itkImageF3 or itkImageSourceIF3") > > It gives error for the line where we set the input to waterPre, the > last-but-one line of this script - > waterPre.SetInput(projReader.GetOutput()). The error message is TypeError: > Expecting argument of type itkImageF3 or itkImageSourceIF3. As far as I > know, I have replicated the code from the example available for SimpleRTK. > Note, I have created a folder called F:\RTKDir\, which has the contents of > the archive "beam_hardening.tgz" have been extracted there. > > So, my questions are: > 1. Have the input types been changed for the WaterPreCorrection Filter, > since the posting of the earlier example? > 2. If so, how can I specify projections as read in from 360 files as > inputs to this filter? > > Any pointers in this regard will be greatly appreciated. > > Thanks and Regards > - Amarnath > > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.kudrna83 at gmail.com Thu Jul 25 09:48:00 2019 From: pavel.kudrna83 at gmail.com (Pavel Kudrna) Date: Thu, 25 Jul 2019 15:48:00 +0200 Subject: [Rtk-users] CT recon - Matrix and paramaters are not consistent Message-ID: <5d39b310.1c69fb81.5cc82.d4d1@mx.google.com> Hello everybody, Would be anybody so kind to give me a brief introduction what is going on when I get error with ITK back-projection? The numbers in matrixes seems to be same. I am running simple script containing rtkfdk -v -p . -r output_mha.mha -o result.mha -g output_xml.xml --dimension 200 200 200 --spacing 0.1 command. I got this. I am using docker image under win 10 and power shell. Thank you? Kind regards? Pavel -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 630BE43B26804F21AEAD9509001A1E6F.png Type: image/png Size: 163024 bytes Desc: not available URL: From simon.rit at creatis.insa-lyon.fr Thu Jul 25 11:10:14 2019 From: simon.rit at creatis.insa-lyon.fr (Simon Rit) Date: Thu, 25 Jul 2019 17:10:14 +0200 Subject: [Rtk-users] CT recon - Matrix and paramaters are not consistent In-Reply-To: <5d39c565.1c69fb81.90047.cbff@mx.google.com> References: <5d39b310.1c69fb81.5cc82.d4d1@mx.google.com> <5d39c565.1c69fb81.90047.cbff@mx.google.com> Message-ID: Thanks for the feedback. Indeed, your geometry file was fine on my linux box. This solves the thread, nothing else to do. Cheers, Simon On Thu, Jul 25, 2019 at 5:06 PM Pavel Kudrna wrote: > Simon, > > > > I found out what is wrong. I computed the XML on win .NET C# and then put > it into shared folder and invoked the command in docker which is Linux. The > same goniometry functions are not giving same results when computed on > different systems. When I invoked the xml generating script on linux > (docker) it produced correct matrixes. > > > > So this is the reason. Strange what is written in first sentence in here > https://stackoverflow.com/questions/21183477/windows-vs-linux-math-result-difference > :) > > > > How to make this thread solved please? I am new here, so appologize my > question. > > > > Thank you? > > > > p. > > > > *Od: *Simon Rit > *Odesl?no:*?tvrtek 25. ?ervence 2019 16:36 > *Komu: *Pavel Kudrna > *P?edm?t: *Re: [Rtk-users] CT recon - Matrix and paramaters are not > consistent > > > > Hi, > > There is a consistency check between the matrix and the parameters which > are both included in the geometry file and redundant, see the code here: > > > https://github.com/SimonRit/RTK/blob/master/src/rtkThreeDCircularProjectionGeometryXMLFileReader.cxx#L161-L176 > > But I don't see any inconsistency so I don't understand what's the problem > here. Can you send your geometry file? > > Thanks, > > Simon > > > > PS: your 200 200 200 should be changed to "200 200 200" or 200,200,200 > > > > On Thu, Jul 25, 2019 at 3:48 PM Pavel Kudrna > wrote: > > Hello everybody, > > > > Would be anybody so kind to give me a brief introduction what is going on > when I get error with ITK back-projection? The numbers in matrixes seems to > be same. I am running simple script containing *rtkfdk -v -p . -r > output_mha.mha -o result.mha -g output_xml.xml --dimension 200 200 200 > --spacing 0.1 * command. I got this. I am using docker image under win 10 > and power shell. > > > > Thank you? > > > > Kind regards? > > > > Pavel > > > > > > _______________________________________________ > Rtk-users mailing list > Rtk-users at public.kitware.com > https://public.kitware.com/mailman/listinfo/rtk-users > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lomahu at gmail.com Sun Jul 28 11:14:59 2019 From: lomahu at gmail.com (Howard) Date: Sun, 28 Jul 2019 11:14:59 -0400 Subject: [Rtk-users] wrong projection geometry? Message-ID: Hi, I tried to run the application rtkfdk to reconstruct CBCT from 180 projections (from 0 degree to 180 degree only) that were generated using Gate simulation. Here is the geometry of the simulation: a cylindrical phantom (radius=8mm, height=20mm) sitting on a turntable X-ray source to isocenter (center of the cylindrical phantom) = 80mm (SAD) Flat panel imager (60mm x 60mm) to isocenter = 80mm (SDD=160mm) x direction: perpendicular to y direction which is the direction from detector to X-ray source; z direction: turntable rotation axis and pointing upward I used rtksimulatedgeometry application to generate the geometry xml file following the simulation geometry with the command: rtksimulatedgeometry -n 180 --arc 180 -o geo.xml --sid 80 -sdd 160 --proj_iso_x -30 --proj_iso_y -30 Subsequently the CBCT was reconstructed with the rtkfdk application with the command: rtkfdk -g geo.xml -p . -r proj.mha -o test.mha --spacing 0.1 0.1 0.2 --dimension 160,160,100 --origin -8 -8 -10 However, the reconstruction result does not look correct. Particularly the axial and sagittal views have a lot of streaks. For your reference, I am sharing the snapshots of the projections and the reconstructed CBCT in the following link: projection screenshot: https://ibb.co/PCTjzrt reconstruction screenshot: https://ibb.co/QCjjvQt What did I do wrong or miss? Or streaks are due to partial projections, ie, only 180 views? Your help would be greatly appreciated. Best, Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: