lesion segmentation

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
pdeman
Posts: 39
Joined: Thu Sep 17, 2015 4:09 pm
Location: moving sometimes

lesion segmentation

Post by pdeman »

Hi,
is there a tool in brainvisa to automatically perform a 3D ROI of a lesion (part of the brain removed, so no need of a crazy algorithm).
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: lesion segmentation

Post by riviere »

Hi,
There is no specific lesion segmentation tool in BrainVisa. You can try the "magic brush" tool of the ROI drawing toolbox of Anatomist (I don't guarantee that it is the exact tool you need...)
Denis
pdeman
Posts: 39
Joined: Thu Sep 17, 2015 4:09 pm
Location: moving sometimes

Re: lesion segmentation

Post by pdeman »

thanks.
I'll take a look at the magic brush soon.
pdeman
Posts: 39
Joined: Thu Sep 17, 2015 4:09 pm
Location: moving sometimes

Re: lesion segmentation

Post by pdeman »

would it be possible to subtract the T1 post resection from the T1 pre resection ?
that could help me.
I have the transformation matrix so I can see them coregistered on anatomist. But I don't know how to subtract the two images. I can do the fusion, but not the subtraction for now.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: lesion segmentation

Post by riviere »

Hi,
You mean using the image processing tools, or visually ?
You can do many operations using masking and additions/substractions, using AimsMask, cartoLinearComb.py or other commands. To do so you will need to resample one of the images to the space of the other (AimsResample)...
Visually in anatomist, there is no "substraction" mode, that's right, you can perhaps do something by inverting the colormap of one of the images in the fusion (setting the max lower than the min).
I don't know if I am answering your question ?
Denis
pdeman
Posts: 39
Joined: Thu Sep 17, 2015 4:09 pm
Location: moving sometimes

Re: lesion segmentation

Post by pdeman »

I was hopping a visualization method, to not have to resample the images.
I'll try the inversion of the colormap and fusion, I didn't thought about it but it should worls.
otherwise I'll resample.

Thanks !
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: lesion segmentation

Post by riviere »

OK. The thing is that fusions in Anatomist are merging images after going through the colormaps: they are working in RGB space, and not in image space, thus they do not provide direct ways to perform image-space operations (additions, subtractions or masking). That's something which has been in the TODO list for years... It would be useful.
Denis
pdeman
Posts: 39
Joined: Thu Sep 17, 2015 4:09 pm
Location: moving sometimes

Re: lesion segmentation

Post by pdeman »

I have a logical array of my lesion that I want to convert into ROI (in order to use roi tools to correct manually the lesion segmentation, the eraser mainly as my automatic segmentation can take a little bit of the ventricles sometimes).
and reconvert it after in logical array. is that possible ?
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: lesion segmentation

Post by riviere »

Yes it is possible.
Anatomist uses its own format for ROIs (".arg"), which is a "graph" format (also used for sulci and other sets of objects). Conversion from/to label images is possible using the "AimsGraphConvert" command:
To convert an image to ROIs set:

Code: Select all

AimsGraphConvert -i image.nii -o roi.arg
To convert a ROI set to a labels image, it is a bit more indirect:

Code: Select all

AimsGraphConvert -o roi.arg -o roi_image.arg --volume
This actually converts a .arg ROI graph into another .arg graph, but which contains an image (instead of voxels lists). The label image is found in the roi_volume.data directory then (should be named something like "roi_image_Volume.nii")

In BrainVisa there are some processes wrapping it: in Tools/converters: Volume To ROI Converter" and "Graph To Volume Converter".
Denis
pdeman
Posts: 39
Joined: Thu Sep 17, 2015 4:09 pm
Location: moving sometimes

Re: lesion segmentation

Post by pdeman »

I works perfectly with a lot of manual step.
I try to reduce the number of manual step for neurologist users and I have some problem.

I have my nii file which is in the directory '/Center/Subject/Resection/' with a resection.nii and a resection.nii.minf files.

if I do

Code: Select all

ret = subprocess.call(['AimsGraphConvert', '-i', str(di_resec.fullPath()), '-o', str(os.path.dirname(di_resec.fullPath()))+'tmproi.arg'])
it works perfectly. I have the tmproi.arg file (it generates : '/Center/Subject/Resection/tmproi.arg' and '/Center/Subject/Resection/tmproi.data') that I can open via the roi gui and modify etc ... but I have to add manually the referential etc ...

I tried to do that to do more step on the roi file via command line

Code: Select all

wdi_resec_roi = WriteDiskItem( 'ROI', 'Graph and Data' )
di_resec_roi = wdi_resec_roi.findValue({'subject':self.brainvisaPatientAttributes['subject'], 'center':self.currentProtocol, 'acquisition':'Resection'})
ret = subprocess.call(['AimsGraphConvert', '-i', str(di_resec.fullPath()), '-o', di_resec_roi.fullPath()])
if ret < 0:
	QtGui.QMessageBox.warning(self, "Erreur", "roi conversion failed")
	return
neuroHierarchy.databases.insertDiskItem( di_resec_roi, update=True )
self.transfoManager.setReferentialTo(di_resec_roi, self.diskItems['T1pre'].attributes()['referential'] )
but the

Code: Select all

ret = subprocess.call(['AimsGraphConvert', '-i', str(di_resec.fullPath()), '-o', di_resec_roi.fullPath()])
line doesn't work.
I have this error message:

Code: Select all

ret = subprocess.call(['AimsGraphConvert', '-i', str(di_resec.fullPath()), '-o', di_resec_roi.fullPath()])
saving all
/center/subject/diffusion/Resection/default_analysis/default_tracking_session/regions_subject_default_tracking_session.data: No such file or directory
the folder /center/subject/diffusion doesn't exist but why is it looking for a diffusion folder ?
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: lesion segmentation

Post by riviere »

Hi,
OK several things are going on in your example:
- you are using the "ROI" type, which is used through derived (more specialized) types only in the database organization provided by brainvisa. Thus finding the placement of an output data of this type is likeky to be ambiguous or trigger a rule designed for another kind of specialized data. Here it happens that the (old) tracking toolboxes is using ROIs (of type " Tracking regions graph", inheriting "ROI"), which can be placed in the files organization with a higher priority than other ROI types. Thus it is what "wdi_resec_roi.findValue(...)" returns you: di_resec_roi.type() is not directly a "ROI" here.
You should rather define a subtype for your needs and define a placement for it in the hierarchy.
- As you define wdi_resec_roi and its value duriring the execution of a script (it is not a parameter of a process), BrainVisa cannot create the directory which will hold the data. So here AimsGraphConvert is trying to write in a non-existing directory. If you have to do so, you must take care of creating the parent directories first.
- As I said in the last message, there are already processes to convert between label images and graphs in BV: "Volume To ROI Converter" and "Graph To Volume Converter". (You can use them from a script if needed)

Denis
Post Reply