Page History

Key

• This line was removed.
• Formatting was changed.

...

• Download projection_density for a VISp VISal injection SectionDataSet (id=287495026) at 50 μm resolution
Code Block
```http://api.brain-map.org/grid_data/download_file/287495026??image=projection_density&resolution=50
```

...

Code Block
```% -------------------------------
%
% For example:
%
% Requires: MATLAB 7.13 (R2011b)
%
%
% ---------------------------------

%
% Note that reader swaps the order of the first two axes
%
% AVGT = 3-D matrix of average_template
% PDENS = 3-D matrix of projection_density
%

% Display one coronal section
figure;imagesc(squeeze(AVGT(:,184,:)));colormap(gray(256)); axis equal;
figure;imagesc(squeeze(PDENS(:,184,:)));colormap(jet(256)); axis equal;
```

Example Python code snippet to read in the 50 µm injection_density and injection_fraction and compute an injection centroid:

Code Block
```
# -------------------------------
#
# Install pynrrd: https://github.com/mhe/pynrrd
#
#
# ---------------------------------
import nrrd
import numpy as np
import matplotlib.pyplot as plt
import Image

#
# Note that reader swaps the order of the first two axes
#
# INJDENS = 3-D matrix of injection_density
# INJFRAC = 3-D matrix of injection_fraction
#

# find all voxels with injection_fraction >= 1
injection_voxels = np.where( INJFRAC >= 1 )
injection_density = INJDENS[injection_voxels]
sum_density = sum(injection_density)

# compute centroid in CCF coordinates
centroid = map( lambda x : sum( injection_density * x ) / sum_density * 50, injection_voxels)
print centroid
```

...