Access the individual slices of a volume segmentation from python

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Access the individual slices of a volume segmentation from python

Sofia Semana Valentin
Hello Slicer community,

I'm creating a python module and I need to make some changes to each slice of a volume segmentation (which is a vtkMRMLLabelMapVolumeNode). How could I acces to the individual slices of that node from python?

Thank you very much!

Sofia

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Access the individual slices of a volume segmentation from python

Fernando
Hi Sofia,

You can do
numpyArray = slicer.util.array(yourLabelMapVolumeNode.GetID())


Best,
Fernando

2017-03-15 17:41 GMT+01:00 Sofia Semana Valentin <[hidden email]>:
Hello Slicer community,

I'm creating a python module and I need to make some changes to each slice of a volume segmentation (which is a vtkMRMLLabelMapVolumeNode). How could I acces to the individual slices of that node from python?

Thank you very much!

Sofia

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Access the individual slices of a volume segmentation from python

Sofia Semana Valentin
In reply to this post by Sofia Semana Valentin
Thank you very much Fernando!

I may need some more help with this. I have two questions about the array data.
  1. What should I do to access only the axial plane data?
  2. And, is there a way to find how many pixels does each slice have (inside the node), and what's the area in mm^2?
Thanks,
Sofia

2017-03-15 17:47 GMT+01:00 Fernando Pérez-García <[hidden email]>:
Hi Sofia,

You can do
numpyArray = slicer.util.array(yourLabelMapVolumeNode.GetID())


Best,
Fernando

2017-03-15 17:41 GMT+01:00 Sofia Semana Valentin <[hidden email]>:
Hello Slicer community,

I'm creating a python module and I need to make some changes to each slice of a volume segmentation (which is a vtkMRMLLabelMapVolumeNode). How could I acces to the individual slices of that node from python?

Thank you very much!

Sofia

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ



_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Access the individual slices of a volume segmentation from python

lasso2

Another approach that you can try is to segment a single slice using Segment Editor and then get the surface area of the segment using Segment Statistics. The reported area is the area of both sides of the slice, so to get a simple cross-sectional area, you have to divide the reported surface area by 2.

 

Andras

 

From: slicer-devel [mailto:[hidden email]] On Behalf Of Sofia Semana Valentin
Sent: March 15, 2017 15:25
To: Fernando Pérez-García <[hidden email]>
Cc: SPL Slicer Devel <[hidden email]>
Subject: Re: [slicer-devel] Access the individual slices of a volume segmentation from python

 

Thank you very much Fernando!

 

I may need some more help with this. I have two questions about the array data.

  1. What should I do to access only the axial plane data?
  2. And, is there a way to find how many pixels does each slice have (inside the node), and what's the area in mm^2?

Thanks,

Sofia

 

2017-03-15 17:47 GMT+01:00 Fernando Pérez-García <[hidden email]>:

Hi Sofia,

 

You can do

numpyArray = slicer.util.array(yourLabelMapVolumeNode.GetID())

 

 

Best,

Fernando

 

2017-03-15 17:41 GMT+01:00 Sofia Semana Valentin <[hidden email]>:

Hello Slicer community,

 

I'm creating a python module and I need to make some changes to each slice of a volume segmentation (which is a vtkMRMLLabelMapVolumeNode). How could I acces to the individual slices of that node from python?

 

Thank you very much!

 

Sofia

 

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ

 

 


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Access the individual slices of a volume segmentation from python

Sofia Semana Valentin
In reply to this post by Sofia Semana Valentin
Thank you Andras!

I tried this option, but I don't know how to get all 2D segments of the element of interest at once instead of doing it one by one.
On the other hand, I'm trying to compare their statistics, so the Segment Editor is perfect for that part, thanks.

Maybe it can be done someway by importing SimpleITK utilities in the python module, I'm not sure.

Thanks you,
Sofia

2017-03-15 21:38 GMT+01:00 Andras Lasso <[hidden email]>:

Another approach that you can try is to segment a single slice using Segment Editor and then get the surface area of the segment using Segment Statistics. The reported area is the area of both sides of the slice, so to get a simple cross-sectional area, you have to divide the reported surface area by 2.

 

Andras

 

From: slicer-devel [mailto:[hidden email]] On Behalf Of Sofia Semana Valentin
Sent: March 15, 2017 15:25
To: Fernando Pérez-García <[hidden email]>
Cc: SPL Slicer Devel <[hidden email]>
Subject: Re: [slicer-devel] Access the individual slices of a volume segmentation from python

 

Thank you very much Fernando!

 

I may need some more help with this. I have two questions about the array data.

  1. What should I do to access only the axial plane data?
  2. And, is there a way to find how many pixels does each slice have (inside the node), and what's the area in mm^2?

Thanks,

Sofia

 

2017-03-15 17:47 GMT+01:00 Fernando Pérez-García <[hidden email]>:

Hi Sofia,

 

You can do

numpyArray = slicer.util.array(yourLabelMapVolumeNode.GetID())

 

 

Best,

Fernando

 

2017-03-15 17:41 GMT+01:00 Sofia Semana Valentin <[hidden email]>:

Hello Slicer community,

 

I'm creating a python module and I need to make some changes to each slice of a volume segmentation (which is a vtkMRMLLabelMapVolumeNode). How could I acces to the individual slices of that node from python?

 

Thank you very much!

 

Sofia

 

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ

 

 



_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Access the individual slices of a volume segmentation from python

lasso2
In reply to this post by Sofia Semana Valentin

This example script shows how to merge all segments into one vtkImageData (stored in ‘mergedImage’ variable), run a filter on it, and put back the result into the segmentation node:

https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How_to_run_segment_editor_effects_from_a_script

 

Andras

 

From: Sofia Semana Valentin [mailto:[hidden email]]
Sent: March 15, 2017 17:55
To: Andras Lasso <[hidden email]>
Cc: Fernando Pérez-García <[hidden email]>; SPL Slicer Devel <[hidden email]>
Subject: Re: [slicer-devel] Access the individual slices of a volume segmentation from python

 

Thank you Andras!

 

I tried this option, but I don't know how to get all 2D segments of the element of interest at once instead of doing it one by one.

On the other hand, I'm trying to compare their statistics, so the Segment Editor is perfect for that part, thanks.

 

Maybe it can be done someway by importing SimpleITK utilities in the python module, I'm not sure.

 

Thanks you,

Sofia

 

2017-03-15 21:38 GMT+01:00 Andras Lasso <[hidden email]>:

Another approach that you can try is to segment a single slice using Segment Editor and then get the surface area of the segment using Segment Statistics. The reported area is the area of both sides of the slice, so to get a simple cross-sectional area, you have to divide the reported surface area by 2.

 

Andras

 

From: slicer-devel [mailto:[hidden email]] On Behalf Of Sofia Semana Valentin
Sent: March 15, 2017 15:25
To: Fernando Pérez-García <[hidden email]>
Cc: SPL Slicer Devel <[hidden email]>
Subject: Re: [slicer-devel] Access the individual slices of a volume segmentation from python

 

Thank you very much Fernando!

 

I may need some more help with this. I have two questions about the array data.

  1. What should I do to access only the axial plane data?
  2. And, is there a way to find how many pixels does each slice have (inside the node), and what's the area in mm^2?

Thanks,

Sofia

 

2017-03-15 17:47 GMT+01:00 Fernando Pérez-García <[hidden email]>:

Hi Sofia,

 

You can do

numpyArray = slicer.util.array(yourLabelMapVolumeNode.GetID())

 

 

Best,

Fernando

 

2017-03-15 17:41 GMT+01:00 Sofia Semana Valentin <[hidden email]>:

Hello Slicer community,

 

I'm creating a python module and I need to make some changes to each slice of a volume segmentation (which is a vtkMRMLLabelMapVolumeNode). How could I acces to the individual slices of that node from python?

 

Thank you very much!

 

Sofia

 

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ

 

 

 


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Access the individual slices of a volume segmentation from python

andrey.fedorov
In reply to this post by Sofia Semana Valentin
On Wed, Mar 15, 2017 at 3:24 PM, Sofia Semana Valentin
<[hidden email]> wrote:
> And, is there a way to find how many pixels does each slice have (inside the
> node), and what's the area in mm^2?
>

You can use pyradiomics library [1] to calculate various quantitative
features for segmentation/image pair. Number of pixels and area are
some of the simplest one. A Slicer extension [2] that will provide
access to pyradiomics is in development, and you can build it, but it
is not yet available in the ExtensionManager.

[1] https://github.com/radiomics/pyradiomics
[2] https://github.com/radiomics/SlicerRadiomics

> Thanks,
> Sofia
>
> 2017-03-15 17:47 GMT+01:00 Fernando Pérez-García <[hidden email]>:
>>
>> Hi Sofia,
>>
>> You can do
>> numpyArray = slicer.util.array(yourLabelMapVolumeNode.GetID())
>>
>>
>> Best,
>> Fernando
>>
>> 2017-03-15 17:41 GMT+01:00 Sofia Semana Valentin
>> <[hidden email]>:
>>>
>>> Hello Slicer community,
>>>
>>> I'm creating a python module and I need to make some changes to each
>>> slice of a volume segmentation (which is a vtkMRMLLabelMapVolumeNode). How
>>> could I acces to the individual slices of that node from python?
>>>
>>> Thank you very much!
>>>
>>> Sofia
>>>
>>> _______________________________________________
>>> slicer-devel mailing list
>>> [hidden email]
>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>> To unsubscribe: send email to [hidden email] with
>>> unsubscribe as the subject
>>>
>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>>
>>
>
>
> _______________________________________________
> slicer-devel mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
> To unsubscribe: send email to [hidden email] with
> unsubscribe as the subject
> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Access the individual slices of a volume segmentation from python

Sofia Semana Valentin
In reply to this post by Sofia Semana Valentin
Thank you all!

I cannot access the segment editor. Should it be included in the SlicerRT extension? Because I haven't been able to reach it.

I get this message:
Imágenes integradas 1

Best,

Sofia



2017-03-16 2:31 GMT+01:00 Andrey Fedorov <[hidden email]>:
On Wed, Mar 15, 2017 at 3:24 PM, Sofia Semana Valentin
<[hidden email]> wrote:
> And, is there a way to find how many pixels does each slice have (inside the
> node), and what's the area in mm^2?
>

You can use pyradiomics library [1] to calculate various quantitative
features for segmentation/image pair. Number of pixels and area are
some of the simplest one. A Slicer extension [2] that will provide
access to pyradiomics is in development, and you can build it, but it
is not yet available in the ExtensionManager.

[1] https://github.com/radiomics/pyradiomics
[2] https://github.com/radiomics/SlicerRadiomics

> Thanks,
> Sofia
>
> 2017-03-15 17:47 GMT+01:00 Fernando Pérez-García <[hidden email]>:
>>
>> Hi Sofia,
>>
>> You can do
>> numpyArray = slicer.util.array(yourLabelMapVolumeNode.GetID())
>>
>>
>> Best,
>> Fernando
>>
>> 2017-03-15 17:41 GMT+01:00 Sofia Semana Valentin
>> <[hidden email]>:
>>>
>>> Hello Slicer community,
>>>
>>> I'm creating a python module and I need to make some changes to each
>>> slice of a volume segmentation (which is a vtkMRMLLabelMapVolumeNode). How
>>> could I acces to the individual slices of that node from python?
>>>
>>> Thank you very much!
>>>
>>> Sofia
>>>
>>> _______________________________________________
>>> slicer-devel mailing list
>>> [hidden email]
>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>> To unsubscribe: send email to [hidden email] with
>>> unsubscribe as the subject
>>>
>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>>
>>
>
>
> _______________________________________________
> slicer-devel mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
> To unsubscribe: send email to [hidden email] with
> unsubscribe as the subject
> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Access the individual slices of a volume segmentation from python

lasso2

As the error message states, you haven’t defined segmentationNode variable

 

From: slicer-devel [mailto:[hidden email]] On Behalf Of Sofia Semana Valentin
Sent: March 16, 2017 9:52
To: Andrey Fedorov <[hidden email]>
Cc: SPL Slicer Devel <[hidden email]>
Subject: Re: [slicer-devel] Access the individual slices of a volume segmentation from python

 

Thank you all!

 

I cannot access the segment editor. Should it be included in the SlicerRT extension? Because I haven't been able to reach it.

 

I get this message:

Imágenes integradas 1

 

Best,

 

Sofia

 

 

 

2017-03-16 2:31 GMT+01:00 Andrey Fedorov <[hidden email]>:

On Wed, Mar 15, 2017 at 3:24 PM, Sofia Semana Valentin
<[hidden email]> wrote:
> And, is there a way to find how many pixels does each slice have (inside the
> node), and what's the area in mm^2?
>

You can use pyradiomics library [1] to calculate various quantitative
features for segmentation/image pair. Number of pixels and area are
some of the simplest one. A Slicer extension [2] that will provide
access to pyradiomics is in development, and you can build it, but it
is not yet available in the ExtensionManager.

[1] https://github.com/radiomics/pyradiomics
[2] https://github.com/radiomics/SlicerRadiomics


> Thanks,
> Sofia
>
> 2017-03-15 17:47 GMT+01:00 Fernando Pérez-García <[hidden email]>:
>>
>> Hi Sofia,
>>
>> You can do
>> numpyArray = slicer.util.array(yourLabelMapVolumeNode.GetID())
>>
>>
>> Best,
>> Fernando
>>
>> 2017-03-15 17:41 GMT+01:00 Sofia Semana Valentin
>> <[hidden email]>:
>>>
>>> Hello Slicer community,
>>>
>>> I'm creating a python module and I need to make some changes to each
>>> slice of a volume segmentation (which is a vtkMRMLLabelMapVolumeNode). How
>>> could I acces to the individual slices of that node from python?
>>>
>>> Thank you very much!
>>>
>>> Sofia
>>>
>>> _______________________________________________
>>> slicer-devel mailing list
>>> [hidden email]
>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>> To unsubscribe: send email to [hidden email] with
>>> unsubscribe as the subject
>>>
>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>>
>>
>
>
> _______________________________________________
> slicer-devel mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
> To unsubscribe: send email to [hidden email] with
> unsubscribe as the subject
> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ

 


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ