ROI/mask based extraction

401 views
Skip to first unread message

Linden Parkes

unread,
Jun 2, 2014, 1:33:07 AM6/2/14
to neurosy...@googlegroups.com
Hi Neurosynthers,

I have a question relating to the neurosynth_demo script. It highlights the capacity for neurosynth to be passed a mask image or a list coordinates. The tutorial covers passing in some coordinates but I'm wondering if someone can provide some details on how to pass in a mask image? (I'm quite inexperienced with Python).
Is it possible to pass in an ROI based on something like a freesurfer segmentation?

Cheers,
Linden

Tal Yarkoni

unread,
Jun 2, 2014, 12:49:18 PM6/2/14
to neurosy...@googlegroups.com

Hi Linden,

The only real constraint on using mask-based study selection is that the mask image should be in the same space as the rest of the Neurosynth data, which is MNI152 2mm. Assuming that's true, it's irrelevant as to what tool generated the image. That said, if you're using a tool like FreeSurfer, which natively stores data in its own format, you'll need to export the segmentation you want to use to to a Nifti or Analyze-format volume (with the right dimensions) that Neurosynth can read, which could present some headaches.

As far as code goes, it's very simple. Assuming you have a nifti image with the right dimensions, selecting studies that report activation in a minimum of, say, 10% of the non-zero voxels in the mask image is as simple as:

ids = dataset.get_ids_by_mask('my_mask_image.nii.gz', threshold=0.1)

...and now ids is a list of the PMIDs of all the studies in the database that pass the threshold. If you want to retrieve the actual image data (as an n_voxels x n_studies matrix) rather than just the study ids, you can pass get_image_data=True, i.e.,

ids = dataset.get_ids_by_mask('my_mask_image.nii.gz', threshold=0.1, get_image_data=True)

Hope that answers your question.

Best,

Tal




--
You received this message because you are subscribed to the Google Groups "neurosynth" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neurosynthlis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Linden Parkes

unread,
Jun 3, 2014, 4:32:14 AM6/3/14
to neurosy...@googlegroups.com
Hi Tal,

Thank you for your speedy reply!
I made a small binary mask using FSL instead of freesurfer to keep things in .nii more easily and it seemed to work well.

I have a follow up question.
Is it possible to conduct meta analytic contrasts on features across two distinct masks. i.e. can I determine whether one feature (such as 'reward') is represented to a greater extent in one region vs another.
This already seems to happen on the website version of neurosynth because you can enter in different spherical ROIs and get z-scores for terms relating to that region and then compare the z-scores for those same features against another ROI.
For example, you get a z-score of 18.63 for 'reward' if you plug in [10 10 -8]. Whereas, if you plug in [10 16 0] the z-score drops to 8.54, implying greater confidence in this features association with the former ROI compared to the latter.

Cheers,
Linden

Tal Yarkoni

unread,
Jun 3, 2014, 11:56:58 AM6/3/14
to neurosy...@googlegroups.com

Hi Linden,

You can do meta-analytic contrasts, but there are some caveats attached. Basically if you pass two sets of ids to the meta-analysis object, it will contrast them directly rather than contrasting just one set of studies with all the other studies in the database. So, for example, you can do something like:

ids1 = dataset.get_ids_by_mask('mask1.nii.gz')   # studies active in first mask
ids2 = dataset.get_ids_by_mask('mask2.nii.gz')   # studies active in second mask
meta = meta.MetaAnalysis(dataset, ids1, ids2)   # run meta-analysis
meta.save_results('/save/my/files/here/')    # save images

The caveat to doing this is that I haven't thought very hard about whether this is actually a sensible way to compare two sets of studies. Basically the way it works right now is it just takes the universe of studies to be the union of the two sets, rather than the database as a whole. Then it just runs a standard analysis on the first set of studies. This seems reasonable to me, and I don't think it implies any unreasonable assumptions, but I could be wrong. So, buyer beware, I guess.

Best,

Tal



--

Linden Parkes

unread,
Jun 4, 2014, 9:12:52 AM6/4/14
to neurosy...@googlegroups.com
Hi Tal,

Thank you very much for this.

Sorry, to loop back to the 'get_image_data=True' bit from your previous response.
Is it possible to use that n_voxels x n_studies matrix to do a meta-analysis on a voxel-wise basis? Im wondering whether I can get a vector of features for each voxel in a mask (e.g. striatum) and then run some clustering to identify different striatal sub-regions based on features.

Cheers,
Linden

Tal Yarkoni

unread,
Jun 8, 2014, 3:26:19 AM6/8/14
to neurosy...@googlegroups.com

Hi Linden,

Sure, you can do whatever you like with the voxels x studies matrix. But I would suggest working with it directly rather than retrieving it with various API calls. Just get dataset.image_table.data and dataset.feature_table.data, which contain the activation and feature data, respectively. The former is a voxel x study numpy array; the latter is a study x feature pandas DataFrame (you can extract the underlying numpy array from the latter with .values).

Best,

Tal



--

Linden Parkes

unread,
Jun 10, 2014, 3:05:58 AM6/10/14
to neurosy...@googlegroups.com

Hi Yarkoni,


I could get the .values to work.

Is this what you meant? —> xx = dataset.feature_table.data.values


Cheers,

Linden

Tal Yarkoni

unread,
Jun 10, 2014, 5:18:41 AM6/10/14
to neurosy...@googlegroups.com

Yep! That will give you back a numpy array. If you exclude the .values, you'll get back a pandas DataFrame (which gives you some nice tools for slicing the data).

Tal


--

Linden Parkes

unread,
Jun 10, 2014, 6:34:08 AM6/10/14
to neurosy...@googlegroups.com
Oops! sorry I made a careless mistake.
I meant to say I COULDN'T get the .values to work.

...

But just now I went back to get a screenshot of the error I was getting today and it worked...go figure...maybe it sensed your presence..

Also, when I load in the dataset I get many occurrences of this warning
>>>
INFO   transformations No transformation named 'UNKNOWN' found; coordinates left untransformed.
INFO:neurosynth.transformations:No transformation named 'UNKNOWN' found; coordinates left untransformed.
Is this normal? Is this just related to, in your methods paper, where you refer to studies not being classified as either MNI or T88 and therefore marked unknown and left untransformed?

So now that I'm looking at the arrays, what do the values represent? Take dataset.feature_table.data for example. I can see that study 10769249 - 'world' has a value of 0.077064. Is this a z-score? And then how does this relate to the corresponding study cell in the dataset.image_table.data array?
Sorry, am quite unfamiliar with Python.

Cheers,
Linden


--
You received this message because you are subscribed to a topic in the Google Groups "neurosynth" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neurosynthlist/2t7RdrDTrYY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neurosynthlis...@googlegroups.com.

Tal Yarkoni

unread,
Jun 10, 2014, 6:53:09 AM6/10/14
to neurosy...@googlegroups.com

You can safely ignore that message. Yes, it just reflects the fact that studies that aren't detected as being in MNI or T88 space are left untransformed.

The values are the tf-idf transformed counts of words in the abstract. Tf-idf is a standard transformation that normalizes word counts to account for both relative word frequency across an entire corpus and the individual document in question. You can basically think of the resulting value as an importance metric--i.e., higher values imply that a term is more important to that document.

In practice, the default analysis stream in Neurosynth just dichotomizes at a particular threshold (i.e., every study above a particular tf-idf value is considered to be "about" that term, and ever study below the value is considered to be unrelated).

There is no relationship between this and the values in the image_table.data array. The latter just contains binary values, where a 1 indicates that the study reported activation in the corresponding voxel, and a 0 indicates that the study did not report activation in the corresponding voxel. Voxels are in rows, studies are in columns. (Whereas for the feature_table array, studies are in rows, features are in columns.)

Tal


Linden Parkes

unread,
Jun 10, 2014, 7:11:36 AM6/10/14
to neurosy...@googlegroups.com
Ah ok, so I could use this information to say "these studies reported activation within the voxels in X mask" (i.e. image_table data) and the once I have those studies I could look at feature_table and say "and the same studies are associated with x y z features" to then imply that region X is associated with x y z features?
Reply all
Reply to author
Forward
0 new messages