From 1509b0a4818e7d3e281becbc125a7717725cac95 Mon Sep 17 00:00:00 2001 From: Philipp Schlegel Date: Sun, 10 Jan 2021 16:18:07 +0000 Subject: [PATCH] add FAFB14 mirror registration --- flybrains/core.py | 22 +++++++++++++++--- flybrains/data/FAFB14_mirror_landmarks.csv | 27 ++++++++++++++++++++++ flybrains/data/README.md | 7 ++++++ flybrains/templates.py | 4 ++-- 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 flybrains/data/FAFB14_mirror_landmarks.csv diff --git a/flybrains/core.py b/flybrains/core.py index 28d48dd..96e6368 100644 --- a/flybrains/core.py +++ b/flybrains/core.py @@ -23,11 +23,17 @@ from navis import transforms import numpy as np +import pandas as pd from .download import get_data_home __all__ = ['register_transforms', 'report'] +# Read in meta data +fp = os.path.dirname(__file__) + +data_filepath = os.path.join(fp, 'data') + @functools.lru_cache() def get_nat_regdirs(verbose=False): @@ -229,10 +235,10 @@ def register_transforms(): transform_type='bridging') # Add transform between JRCFIB2018F (nm) and JRCFIB2018Fum (um) - tr = transforms.affine.AffineTransform(np.diag([1/1e3, 1/1e3, 1/1e3, 1])) + tr = transforms.affine.AffineTransform(np.diag([1e3, 1e3, 1e3, 1])) transforms.registry.register_transform(transform=tr, - source='JRCFIB2018F', - target='JRCFIB2018Fum', + source='JRCFIB2018Fum', + target='JRCFIB2018F', transform_type='bridging') # Add transform between FAFB14um and FAFB14 (nm) @@ -255,3 +261,13 @@ def register_transforms(): source='JFRC2', target='JFRC2010', transform_type='bridging') + + # Add a simple mirror transform for FAFB14 + fp = os.path.join(data_filepath, 'FAFB14_mirror_landmarks.csv') + lm = pd.read_csv(fp) + tr = transforms.thinplate.TPStransform(lm[['x_mirr', 'y_mirr', 'z_mirr']].values, + lm[['x', 'y', 'z']].values) + transforms.registry.register_transform(transform=tr, + source='FAFB14', + target=None, + transform_type='mirror') diff --git a/flybrains/data/FAFB14_mirror_landmarks.csv b/flybrains/data/FAFB14_mirror_landmarks.csv new file mode 100644 index 0000000..a56302f --- /dev/null +++ b/flybrains/data/FAFB14_mirror_landmarks.csv @@ -0,0 +1,27 @@ +label,x,y,z,side,x_mirr,y_mirr,z_mirr,original_side +antler,587201,182007,185345,L,568923,179977,195734,R +dimple1,697109,222823,58876,L,705480,205422,106682,R +dimple2,607100,104989,138065,L,586352,98028,150176,R +dimple3,622471,308005,144728,L,608265,304754,157541,R +dimple4,643639,214585,66168,L,645039,199521,93013,R +LH,733031,146563,152677,L,721699,134702,182934,R +MB1,692958,172890,65884,L,681095,154893,102163,R +MB2,599003,93341,76730,L,591704,85278,90487,R +peak,619804,294979,53835,L,630690,275831,66134,R +SEZ,559790,317818,37401,L,561715,311357,47117,R +vis1,730150,189507,204076,L,731312,183857,235749,R +vis2,680242,344243,170947,L,680339,325281,203112,R +vis3,767124,306692,219120,L,801424,285944,270713,R +antler,476963,179977,195734,R,458685,182007,185345,L +dimple1,340406,205422,106682,R,348777,222823,58876,L +dimple2,459534,98028,150176,R,438786,104989,138065,L +dimple3,437621,304754,157541,R,423415,308005,144728,L +dimple4,400847,199521,93013,R,402247,214585,66168,L +LH,324187,134702,182934,R,312855,146563,152677,L +MB1,364791,154893,102163,R,352928,172890,65884,L +MB2,454182,85278,90487,R,446883,93341,76730,L +peak,415196,275831,66134,R,426082,294979,53835,L +SEZ,484171,311357,47117,R,486096,317818,37401,L +vis1,314574,183857,235749,R,315736,189507,204076,L +vis2,365547,325281,203112,R,365644,344243,170947,L +vis3,244462,285944,270713,R,278762,306692,219120,L diff --git a/flybrains/data/README.md b/flybrains/data/README.md index 6ab3c16..426317d 100644 --- a/flybrains/data/README.md +++ b/flybrains/data/README.md @@ -8,3 +8,10 @@ However, they are in raw voxel coordinates. In contrast, X1,Y1,Z1 (which contain locations in FAFB space) are in nm. See https://github.com/saalfeldlab/elm for the original source of the landmarks. + +`FAFB14_mirror_landmarks.csv` contains landmarks to compensate for left/right +asymmetries in FAFB14. Pairs of landmarks (e.g. "antlers L" and "antler R") +were placed manually to approximately corresponding locations on the left and +right hemisphere. To generate a mirror transform, for each landmark (e.g. +"antlers L") the corresponding landmark on the other side (e.g. "antlers R") +was mirrored to the same side using an affine transform. diff --git a/flybrains/templates.py b/flybrains/templates.py index 03db4fd..173ac96 100644 --- a/flybrains/templates.py +++ b/flybrains/templates.py @@ -640,11 +640,11 @@ class _JRCVNC2018F(FlyTemplateBrain): The JRCVNC2018U reference VNC was constructed as for JRCVNC2018F VNC but pooling both male and female brains. - JRCVNC2018F.surf, was generated in Amira from a 2 micron downsampled, + The JRCVNC2018F mesh, was generated in Amira from a 2 micron downsampled, Lanczos filtered version of the respective template VNC. A surface was then generated with a threshold level of 2800 and then smoothed and downsampled. - JRCVNC2018U.surf, was generated in Amira from a 2 micron downsampled, + The JRCVNC2018U mesh, was generated in Amira from a 2 micron downsampled, Lanczos filtered 8 bit version of the respective template VNC. A surface was then generated with a threshold level of 20 and then smoothed and downsampled.