Tuesday, July 10, 2007

Introducing the Brain Maps API

The Brain Maps API lets you embed Brain Maps in your own web pages with JavaScript. Future versions will enable you to add overlays to brain maps (including markers and polylines) and display shadowed "info windows". The Brain Maps API is a free service, available for any web site that is free to consumers.

Try going to this link to see an example, and once there, try clicking and dragging the image, or clicking on the little tree icon in the upper right. Also, the mouse scroll wheel should zoom you in and out.

Try clicking and dragging the image. Also, the mouse scroll wheel should zoom you in and out.

The code for embedding the Brain Maps API into your own website is simple, requiring just a single line of code:

<iframe src="http://brainmaps.org/ajax-viewer.html?path=http://brainmaps.org/HBP2/c.aethiops/AGM1/AGM1-highres/350/&height=78181&width=92160" width="460" height="267" frameborder="0"></iframe>

It's best to actually download the Brain Maps API and upload the required javascript to your own site, since using just the embedding code above relies on cross-site scripting which is disabled in FireFox.

Additional information is available at http://brainmaps.org/index.php?p=brain-maps-api


webrob said...


I am really interested by your Brain Maps API. Really nice and simple piece of things.
I am yet 2 questions:
1- the demo you provide here http://brainmaps.org/ajax-viewer.php?datid=42&sname=385 implement more features than the current API (toggle labels for example). Do you plan to integrate it to the "standard" API?

2- I would like to see an answer to this question: http://brainmaps.org/ajax-viewer.php?datid=42&sname=385
I also wonder how to just add labels without the need to pass through the slides JSON


neubrain said...

thanks for your interest. About your two questions:
1. toggling the labels can be integrated into the standard api, and is a good idea, so I will look into implementing this soon. Some other functionality, like searching for specific labels, could probably also be integrated, though it might require some work since I'm not sure about javascript's search capabilities. The main difference between the "standard" API and the ajax-viewer.php one is that the ajax-viewer.php has MySQL database integration, which means it is more straightforward to run searches for labels and to have additional functionality. The idea behind the "standard" API was to pack as much functionality into it without requiring MySQL or PHP; hence the use of JSON to specify labels and slide names, which in the php-viewer.php is all contained in a MySQL database instead. So, the short answer to your question is, 'yes', more functionality, like the search feature and toggling labels, will be integrated into the "standard" API.

2. You would like to see an answer to 'which' question? Your url points to ajax-viewer.php. But about adding labels without passing through the slides JSON, let me look into this. If you only have 1 slide, then it makes sense to just have a labels JSON file, instead of creating a slides JSON file. But I'll have to look into this and will get back to you.

Thanks for the suggestions!

webrob said...


Thanks for the quick answer.

1- Toggle is nice feature (even better if you can have different familly of labels, and activate/toggle by familly)...but I understand that simplicity could avoid to do this in the standard API.
One other feature that I see in this implementation and not in the standard one is to be able to link URL when you click on labels. This would be definitely nice.

2- Sorry for my bad link, here it is: http://brainmaps.org/forum/viewtopic.php?id=132

By the way, I have put my own request here too: http://brainmaps.org/forum/viewtopic.php?id=170


neubrain said...

sure thing. I received an email notification about your comment, which was why I was able to reply so quick. Unfortunately, in the forum at brainmaps.org, there is no email notification, so it's not uncommon for posts to go unnoticed or unanswered. Sorry your posts there were not answered sooner. Makes me think that maybe setting up a Google Group, instead of the forum, would have been a better way to go.

All of your ideas are refreshing and very good ones. For example, your idea of having different families of labels that can be individually toggled can be coded into the brainmaps API. Or your idea for having optional links on the labels would be really easy to implement, and I will do this by this Mon and repost the code then. Your idea for having clickable areas is also a really good one, though I have never given thought for how to actually do this. I will take a look at the code you posted in the forum, to try to find out why it doesn't work and perhaps how to make it work. Btw, in one of your forum posts, you mention wanting to add labels without JSON, but what did you have in mind? I was thinking maybe XML, though this would be more verbose and a bit trickier to parse in javascript.

Again, thanks for your ideas. They're really good ones, and I will do what I can to implement them, and also to try to make it easier for other people to contribute too (for example, by posting the brainmaps API code in a more legible format, with comments included to describe the code).

webrob said...

Btw, in one of your forum posts, you mention wanting to add labels without JSON, but what did you have in mind?

Was not my own post but I share the question. The question is not to remove JSON but to just have 1 file for the labels and not be obliged to use the file which define slides in case we have just 1 image... may-be we missunderstood something

neubrain said...

no, I misunderstood that the post was not yours, but the idea makes sense; if you have just one slide or image, then you should not have to use the slides JSON which was really meant for multiple slides. Let me look into this and I'll get back to you by this Mon.

neubrain said...

Ok, I have included a "url" field in the labels JSON file, to include an absolute or relative url for hyperlinking labels. I have also posted the javascript code in a more legible format, which should make it easier for others to play around with it. I still have your other suggestions to consider, and I will, when I free up more time. Thanks again for your suggestions.