This folder contains a collection of scripts used to process histology images, and created structured JSON data to be consumed by the website for the 3d brain and body.
The first part of the document provides context on all the processes carried out, and directory structure. The second part contains instructions for reprocessing data.
The following is the directory structure for a single orientation -- the others follow similarly. After data processing, the full/phalloidin/cartilage
and svgs
directories will contain images, but they start empty initially.
The parts
directory contains folders for all 65
brain regions. Each of these folders contains an image for each slice. The image marks out the specific region as a white area on a black background.
.
└── histology
├── horizontal
| ├── full
| | ├── neurotrace
| | | ├── cartilage # png images, transparent bg
| | | └── original # jpg images, black bg
| | └── phalloidin
| | ├── cartilage # empty directory initially
| | ├── original # jpg images, black bg
| | └── original_with_cartilage # jpg images, black bg
| ├── parts
| | ├── AAB # region marked on each layer
| | ├── ADCl # jpg images, white-on-black
| | └── ...
| └── svgs # empty directory initially
├── sagittal
| └── ...
└── transverse
└── ...
For the images, the following processes are carried out:
- All files are renamed sequentially, 00.* - xx.*
- All images are cropped (more on this below)
- All images are resized
- All the "part" images are inverted
- Phalloidin cartilage images are generated using neurotrace cartilage images as a mask on the phalloidin 'original with cartilage' set
- Annotation SVG files are created for each slice of each orientation, by analyzing all the "parts" images of that slice (more on this below)
- The crop boundaries were identified manually on the browser, and data was recorded in
data/histology.json
- The data contains the original image dimensions, the dimensions that the image was rendered in the browser (
cssDims
) and the crop that was identified relative to the browser rendered image (cssCrop
) - The data also contains
resizeFactor
, a 0 to 1 value indicating how much percentage to scale the images down by, as well as alayerCount
for each orientation, and thestains
names
- This data is stored in
data/brain-hierarchy.csv
anddata/body-hierarchy.csv
- The files contain data on the part
name
,abbreviation
, andfunction
for each region - For the brain data, there is an additional field
hasSides
that specifies whether the region has a left and right side. If so, the abbreviation will be appended withl
andr
when needed - The files also contain
index
field, which uses dash-seperated syntax to specify the hierarchy of the region. This hierarchy is visible on the region menu on the website.
- This data is stored in
data/brain-scene.json
anddata/body-scene.json
- These files were created from a dat.gui export and may contain some amount of redundant data
- They store a mapping between a region abbreviation and a hex code
- Empty histology folders will be populated with relevant data
- Intermediary generated data will be stored in
temp/
- All data will be processed to create
output/brain-data.json
andoutput/body-data.json
- These files contain data formatted like so:
{
region : { ''/*<abbreviation>*/ : ''/*<full part name>*/ },
colors: { ''/*<abbreviation>*/ : ''/*<hex code>*/ },
hierarchy: [
{
name: '',//<name for menu>,
abbreviation: '',//<region abbreviation | null>,
hasSides: '',//<true | false | null>,
function: '',//<region function | null>,
checked: '',//<1 | 0 (for inital menu state)>,
open: '',//<true | false (for inital menu state)>,
children: '',//[ ... nested regions with same structure ....]
}
],
breadcrumbs: {
''/*<abbreviation>*/: {
path: '',//<string for breadcrumb path to region>,
function: '',//<region function>
}
}
}
- For the brain,
output/brain-data.json
contains additional fields:
{
orientations: [
{
name: '' //<orientation name>,
layerCount: -1 //<number of slices>,
width: -1 //<image width>,
height: -1 //<image height>
},
// for each orientation
],
stains: [ "neurotrace", "phalloidin" ],
resizeFactor: 0.2,//<resize factor used for crops>,
partsInLayer: {
''/*<orientation name>*/: {
''/*<slice number>*/: [], //<list of region abbreviations that appear in slice>
}
},
layersWithPart: {
''/*<orientation name>*/: {
''/*<region abbreviation>*/: [], //<list of slice numbers where region appears>
}
}
}
IMPORTANT: Run these scripts from this directory, not scripts/
to ensure bash respects paths
- Ensure histology images from AWS are copied over to
histology/
- Adjust
data/histology.json
if needed, and runnode scripts/calculate-dimensions.js
. This will output totemp/dims.txt
andtemp/histology-core.json
- Run
./scripts/process-images.sh rename
to rename all histology files. (will take a few minutes) - Images for each orientation can be processed simultaneously. It is recommended to do the following in seperate terminal windows so one can catch any errors in the output:
./scripts/process-images.sh horizontal
./scripts/process-images.sh sagittal
./scripts/process-images.sh transverse
- Process the brain data colors, abbreviations etc, by running
node scripts/process-brain.js
, which will outputtemp/brain-pre-svg.json
. NOTE: This script handles certain exceptions in the data, eg. setting color for regions, hiding certain regions at the start. - Create the SVG files and store additional data by running
node scripts/create-svgs.js
, which will create svg files inhistology/ORIENTATION/svgs
and the final data for the website inoutput/brain.json
- Copy over files to the website ...
- Run
scripts/process-body.js
which will outputoutput/body.json