I’m trying to plot the bregma point on the top view using ccf_streamlines with the CCFv3 (10 µm) files. Isocortex2dProjector.project_volume works for me (renders an image), but IsocortexCoordinateProjector.project_coordinates returns NaN for bregma and also for several clearly cortical test points.
Does top.h5 intentionally not cover some streamlines near the midline (so bregma could be outside), and what’s the recommended way to obtain (u, v) for bregma on top?
Am I misusing IsocortexCoordinateProjector.project_coordinates? If so, what is the minimal set of arguments/assumptions you recommend for this use case?
There are a few things going on here. First, the linked source of the bregma CCF coordinate looks like it has the x & z axes in their image swapped from our usual orientation (you have it listed right in your post, but in the linked post’s image they have z as the AP axis and x as ML). So I think the coordinate should be (540, 44, 570) (which would put it right on the midline - that’s actually what the text in the linked post says, but it’s different from the image axes labels).
Either way, this coordinate is outside of the CCF brain and therefore outside of isocortex. It’s too high above the brain, so if you wanted the dorsal-most coordinate that is in the cortex directly below that point, you would want to use (540, 112, 570). You are also right, though, that points directly on the midline are not defined for these projections, so you can shift it over by one voxel: (540, 112, 569), and that will work.
Now, you don’t really need to do all this if you are producing a voxel-scale top view - since the top view really is just like looking straight down at the CCF, its dimensions match up with the 3D CCF space, so you can just put your bregma point at (540 AP, 570 ML) in the top view voxel space. This would not work for the flatmap projections, though.
The reason the other cortical coordinates were not working is because project_coordinates() expects the input coordinates to be in microns, not voxels (the scale parameter is only for the inputs). This is actually mentioned in the docstring for that function, but I appreciate that it can be confusing, so I may try to add an warning message that suggests that possibility if all the inputs seem too small (and therefore outside the brain). If you multiply your coordinates by 10 (for 10 µm voxels), they produce non-NaN projected coordinates, as plotted here:
I had indeed missed that project_coordinates() expects inputs in microns—multiplying 10 µm voxel indices by 10 fixed the issue on my side.
Regarding the CCF coordinate post, there does seem to be some confusion in the figure’s axis labels (AP/DV/ML), so your clarification helps a lot. When constructing the top image from top.nrrd the shape is 1140 (ML), 1320 (AP). Bregma is located in the middle along ML, so 570 is ML. I understand it’s fine to place bregma directly at (AP=540, ML=570) without using project_coordinates, since top is a view from directly above, aligned to the CCF grid.
I’m wondering whether there are any official sources one can cite when selecting the bregma at these coordinates. In any case, judging by the point’s position on the map, it visually matches the location used in the scientific articles I’ve come across.