rii-mango / Papaya

A pure JavaScript medical research image viewer.
Other
551 stars 205 forks source link

Display atlas labels in non-standard space #118

Closed spiropan closed 5 years ago

spiropan commented 6 years ago

Hi Michael,

Is there a way (preferably without having to recompile papaya) to display atlas labels in non-standard (i.e. subject) space? I had thought that modifying the transform tag in the atlas xml file was a way to do this, but that doesn't seem to work. Any thoughts would be greatly appreciated!

Spiro

martinezmj-ims commented 6 years ago

Hi. I've added two new features that might solve this issue for you.

First, you can now set papaya.Container.atlasWorldSpace = false. When false, it will use image indices for the atlas lookup.

Alternatively, you can now set papaya.Container.atlas with you own custom function. See this example here: https://github.com/rii-mango/Papaya/wiki/How-To-Use-Atlases#how-to-make-a-custom-atlas

spiropan commented 6 years ago

Hi,

I think I understand the second custom function solution, but I'm not sure how the first one (setting atlasWorldSpace = false) would work. Does this solution involve the transform information, or are there additional steps involved to be able to attach labels to any non-standard space?

Thanks

On Sun, Jun 3, 2018 at 5:59 PM, Michael Martinez notifications@github.com wrote:

Hi. I've added two new features that might solve this issue for you.

First, you can now set papaya.Container.atlasWorldSpace = false. When false, it will use image indices for the atlas lookup.

Alternatively, you can now set papaya.Container.atlas with you own custom function. See this example here: https://github.com/rii-mango/ Papaya/wiki/How-To-Use-Atlases#how-to-make-a-custom-atlas

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rii-mango/Papaya/issues/118#issuecomment-394194850, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbsrI0iNNGuyuCoVhukP2NNlNNK6371ks5t5FxKgaJpZM4T8q-Z .

martinezmj-ims commented 6 years ago

The first option doesn't involve a transform. What it will do is pass in image indices rather than standard space, real-world coordinates to the atlas's getLabelAtCoordinate() function. For example, maybe you don't have origin/mm information about the atlas volume, but it is in the same space as the subject volume.

That's how I interpreted the request, but let me know if that's not right.

spiropan commented 6 years ago

Do you mean I can specify a custom atlas in subject space using the "atlasURL" parameter

params["atlasURL"] = "atlas/myAtlas.nii.gz";

and set atlasWorldSpace is set to false?

papaya.Container.atlasWorldSpace = false

I don't need to worry about creating a custom build of Papaya that includes the custom atlas?

On Wed, Jun 13, 2018 at 9:44 AM, Michael Martinez notifications@github.com wrote:

The first option doesn't involve a transform. What it will do is pass in image indices rather than standard space, real-world coordinates to the atlas's getLabelAtCoordinate() function. For example, maybe you don't have origin/mm information about the atlas volume, but it is in the same space as the subject volume.

That's how I interpreted the request, but let me know if that's not right.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rii-mango/Papaya/issues/118#issuecomment-396942324, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbsrKPXaYCcqa4JICToX6I0UhyL2STWks5t8RdNgaJpZM4T8q-Z .

martinezmj-ims commented 6 years ago

Sorry for the late reply. I don't see a way around the using Papaya-Builder to build the atlas into the papaya build. But really all it's doing is converting the label XML to JSON and prepending it in the format to papaya.js. If you want to handle creating the label data yourself, you can add something like this to your JavaScript code without needing to "recompile" papaya:

var papaya=papaya||{};
papaya.data=papaya.data||{};
papaya.data.Atlas=papaya.data.Atlas||{};
papaya.data.Atlas.labels = {
    atlas: {
        data: {
            label: "a:b:c:d:e"
        },
        header: {
            transform: "0.9357 0.0029 -0.0072 -1.0423 -0.0065 0.9396 -0.0726 -1.3940 0.0103 0.0752 0.8967 3.6475 0.0000 0.0000 0.0000 1.0000",
            images: {
                summaryimagefile: "Talairach_labels_1mm"
            },
            transformedname: "MNI (Nearest Grey Matter)",
            display: "*.*.*. .*",
            name: "Talairach (Nearest Grey Matter)",
            type: "Label"
        },
        version: 1
    }
};
var papayaLoadableImages = [{
    hide: true,
    name: "Talairach_labels_1mm",
    nicename: "Atlas",
    url: "data/Talairach_labels_1mm.nii.gz"
}];

Would it help to add an example of how to load an image directly in the custom Atlas papaya.Container.atlas function, so then you can do whatever you need to there in your own code.

Let me know if you have suggestions for how best to make integrating custom atlases easier. I know this can be improved.

spiropan commented 6 years ago

No problem, thanks for your reply. I would like to have the labels for the default atlas in Papaya transformed to a space other than MNI. With the example code you just provided, could I do this by replacing the "transform" key with a custom transform value (i.e. one from Talairach to my space of choice other than MNI) and replacing the "data" key values with the original from the papaya.js?

On Sun, Jun 24, 2018 at 6:46 PM Michael Martinez notifications@github.com wrote:

Sorry for the late reply. I don't see a way around the using Papaya-Builder to build the atlas into the papaya build. But really all it's doing is converting the label XML to JSON and prepending it in the format to papaya.js. If you want to handle creating the label data yourself, you can add something like this to your JavaScript code without needing to "recompile" papaya:

var papaya=papaya||{}; papaya.data=papaya.data||{}; papaya.data.Atlas=papaya.data.Atlas||{}; papaya.data.Atlas.labels = { atlas: { data: { label: "a:b:c:d:e" }, header: { transform: "0.9357 0.0029 -0.0072 -1.0423 -0.0065 0.9396 -0.0726 -1.3940 0.0103 0.0752 0.8967 3.6475 0.0000 0.0000 0.0000 1.0000", images: { summaryimagefile: "Talairach_labels_1mm" }, transformedname: "MNI (Nearest Grey Matter)", display: "... .", name: "Talairach (Nearest Grey Matter)", type: "Label" }, version: 1 } }; var papayaLoadableImages = [{ hide: true, name: "Talairach_labels_1mm", nicename: "Atlas", url: "data/Talairach_labels_1mm.nii.gz" }];

Would it help to add an example of how to load an image directly in the custom Atlas papaya.Container.atlas function, so then you can do whatever you need to there in your own code.

Let me know if you have suggestions for how best to make integrating custom atlases easier. I know this can be improved.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rii-mango/Papaya/issues/118#issuecomment-399794508, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbsrJyI2R4XpDnpRlzF5P4Qz-Bqbb3Kks5uABbfgaJpZM4T8q-Z .

martinezmj-ims commented 6 years ago

Yes, in your case, updating transform and transformname should be all you need. Let me know if that doesn't work for you.

spiropan commented 6 years ago

At first pass it didn't seem to work but I'll keep at it.

On a related note, it's not immediately apparent to me how the labels are linked to their coordinates/locations in the image (the labels in the Talairach.xml file don't have any coordinates associated with them and the order doesn't appear to be related to the intensity values in the Talairach_labels_1mm.nii.gz file. Is there something I'm missing?

On Tue, Jun 26, 2018 at 5:55 PM, Michael Martinez notifications@github.com wrote:

Yes, in your case, updating transform and transformname should be all you need. Let me know if that doesn't work for you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rii-mango/Papaya/issues/118#issuecomment-400475689, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbsrKNJjwav6Pl0LSDUt2Wj0gIfCB5wks5uAq3WgaJpZM4T8q-Z .

martinezmj-ims commented 6 years ago

order doesn't appear to be related to the intensity values

Yes, it's the order. In a labels/nifti pair, the image value at any XYZ coordinate is an index into the list of labels.

Try opening the atlas nifti file itself (tests/data/Talairach_labels_1mm.nii.gz) to view in Papaya, with atlas labels turned on, to get a better sense of the mapping.

spiropan commented 6 years ago

Ok. Still can't seem to see it. The first few labels in the Talairach.xml file are in the cerebellum: i.e.

martinezmj-ims commented 6 years ago

The labels at the top of the list will have very lower indices, which means they will appear very black in the image, making them harder to see -- but they're there. If in doubt, take the atlas image into Mango and run a 'Threshold to ROI' for the indices. In the case of your example, indices 1 and 2. This is where it finds them:

screen shot 2018-07-01 at 9 26 35 am
spiropan commented 6 years ago

Thanks for clarifying. I switched to the Harvard-Oxford Cortical Atlas since there more fewer labels. In the Papaya viewer under the labels section I'm only getting single letters instead of full label names. Any idea what I'm doing wrong?

Githubissues.
  • Githubissues is a development platform for aggregating issues.