diff --git a/Browsing Functions/accf2pxs_mm.m b/Browsing Functions/accf2pxs_mm.m new file mode 100644 index 0000000..ded57e6 --- /dev/null +++ b/Browsing Functions/accf2pxs_mm.m @@ -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 \ No newline at end of file diff --git a/Browsing Functions/allenCCF2pxs_mm.m b/Browsing Functions/allenCCF2pxs_mm.m new file mode 100644 index 0000000..999221e --- /dev/null +++ b/Browsing Functions/allenCCF2pxs_mm.m @@ -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 \ No newline at end of file diff --git a/Browsing Functions/apdvml2info.m b/Browsing Functions/apdvml2info.m new file mode 100644 index 0000000..8735ce2 --- /dev/null +++ b/Browsing Functions/apdvml2info.m @@ -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 \ No newline at end of file