Skip to content

Commit

Permalink
depth correction
Browse files Browse the repository at this point in the history
  • Loading branch information
kouichi-c-nakamura committed Aug 3, 2023
1 parent e913028 commit 4de3d02
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Browsing Functions/accf2pxs_mm.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function y_mm = accf2pxs_mm(x_mm)
% convert Allen Common Coordinates into standard values (Paxinos and Franklin)
% x_mm Allen Common Coordinates
% if this is scaler, x_mm should be depth
% if this is n x 3 array, x_mm is an array of the same (or similar) size
% y_mm Paxinos and Franklin coordinates

if size(x_mm,2) ==1
y_mm = 0.921 * x_mm - 0.834; % global
% y = 0.908 * x - 0.957; % local

elseif size(x_mm,2) == 3
% assume that the 2nd column is the DV
y_mm = x_mm;
y_mm(:,2) = 0.921 * x_mm(:,2) - 0.834; % global
% y(:,2) = 0.908 * x(:,2) - 0.957; % local

else
error('unexpected size')
end
18 changes: 18 additions & 0 deletions Browsing Functions/allenCCF2pxs_mm.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function y_mm = accf2pxs_mm(x_mm)
% convert Allen Common Coordinates into standard values (Paxinos and Franklin)
% x_mm Allen Common Coordinates
% y_mm Paxinos and Franklin coordinates

if size(x_mm,2) ==1
y_mm = 0.921 * x_mm - 0.834; % global
% y = 0.908 * x - 0.957; % local

elseif size(x_mm,2) == 3
% assume that the 2nd column is the DV
y_mm = x_mm;
y_mm(:,2) = 0.921 * x_mm(:,2) - 0.834; % global
% y(:,2) = 0.908 * x(:,2) - 0.957; % local

else
error('unexpected size')
end
56 changes: 56 additions & 0 deletions Browsing Functions/apdvml2info.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
function Tapdvml = apdvml2info(apdvml_points, av, st)
% apdvml_points has three columns for ap, dv, and ml
% bregma is 1 x 3 in size
% atlas_resolution in mm
% av 1320 ,800, 1140
% st
%
% see also
% Analyze_Clicked_Points.m

% generate needed values
bregma = allenCCFbregma(); % bregma position in reference data space
atlas_resolution = 0.010; % mm


ap = -(apdvml_points(:,1)-bregma(1))*atlas_resolution;
dv = (apdvml_points(:,2)-bregma(2))*atlas_resolution;
ml = (apdvml_points(:,3)-bregma(3))*atlas_resolution;

% roi_location_curr = [ap dv ml];

% initialize array of region annotations
roi_annotation_curr = cell(size(apdvml_points,1),3);

% loop through every point to get ROI locations and region annotations
tf_rows = true(size(apdvml_points,1),1);
for point = 1:size(apdvml_points,1)

% find the annotation, name, and acronym of the current ROI pixel
depth = ceil(apdvml_points(point,2));
if depth >= 1

ann = av(ceil(apdvml_points(point,1)), ...
depth, ... %NOTE this can take the value of 0 and cause an error (must be >= 1)
ceil(apdvml_points(point,3)));
name = st.safe_name{ann};
acr = st.acronym{ann};

roi_annotation_curr{point,1} = ann;
roi_annotation_curr{point,2} = name;
roi_annotation_curr{point,3} = acr;

else
% ignore this point, too dorsal
roi_annotation_curr{point,1} = NaN;
roi_annotation_curr{point,2} = '';
roi_annotation_curr{point,3} = '';

end

end

Tapdvml = [table(ap, dv, accf2pxs_mm(dv), ml, 'VariableNames',{'ap_mm','dv_mm', 'dv_mm_paxinos', 'ml_mm'}), ...
cell2table(roi_annotation_curr, 'VariableNames', {'annotation', 'name', 'acronym'})];

end

0 comments on commit 4de3d02

Please sign in to comment.