-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclearMapAutomatedIsolation.py
More file actions
89 lines (64 loc) · 2.71 KB
/
clearMapAutomatedIsolation.py
File metadata and controls
89 lines (64 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 12 16:43:27 2018
@author: smith
This script performs automated isolation of regions from transformed ClearMap data.
"""
#automated isolation
#import ClearMap.Analysis.Statistics as stat
import ClearMap.Analysis.Label as lbl
import ClearMap.IO.IO as io
import os
import numpy as np
import ClearMap.Alignment.Resampling as rsp
baseDirectory = '/d2/studies/ClearMap/TRAP2_tdTomato_iDISCO/Cohort1_OCIVSA/FtdTom_1RT/'
sampleName = 'FtdTom_1RT'
region = 'NAc'
AnnotationFile = '/d2/studies/ClearMap/TRAP2_tdTomato_iDISCO/Annotations_Horizontal_8-302_Full.tif'
label = io.readData(AnnotationFile)
label = label.astype('int32')
labelids = np.unique(label)
outside = np.zeros(label.shape, dtype = bool);
"""
In order to find out the level to use, in console input:
>>> lbl.labelAtLevel(r, n)
where r is region ID, and n is level (usually start at 5), if the output is not the
region ID, increase n.
"""
for l in labelids:
if not (lbl.labelAtLevel(l, 6) == 672):
outside = np.logical_or(outside, label == l);
#VTA = 749 (level 5)
#ENT = 909 (level 7)
#mOFC l2/3 = 582 (level 8)
#PBN = 867 (level 6)
#PAG = 795 (level 5)
#DP = 814 (level 6)
#MHb = 483 (level 7)
#Caudoputamen = 672 (level 6)
#Accumbens = 56
#CA3 = 463 (Level 8)
#Prelimbic = 972 (Level 6)
#Endopiriform = 942 (Level 5)
heatmap = np.load('/d2/studies/ClearMap/IA_iDISCO/IA2_LT/cells_transformed_to_Atlas.npy')
#heatmap = io.readData(os.path.join(baseDirectory, 'pvalues_full_vox15.tif'))
#heatmap = io.readData('/d2/studies/ClearMap/FosTRAP_ChR2/F2_LT/cells_heatmap_F2_LT_TrailMap_Reg3.tif')
heatmap[outside] = 0;
io.writeData(os.path.join(baseDirectory, sampleName + '_' + region + '_isolated.tif'), heatmap)
samples = ['IA1_RT', 'IA1_RB', 'IA1_LT', 'IA1_LB',
'IA2_NP', 'IA2_RT', 'IA2_RB', 'IA2_LT', 'IA2_LB']
for mouse in samples:
baseDirectory = '/d2/studies/ClearMap/IA_iDISCO/' + mouse
heatmap = io.readData(os.path.join(baseDirectory, 'cells_heatmap_vox15.tif'))
if not os.path.exists(heatmap):
raise ValueError('Data does not exist. Check naming convention')
for mouse in samples:
baseDirectory = '/d2/studies/ClearMap/IA_iDISCO/' + mouse
sampleName = mouse
region = 'Background'
heatmap = io.readData(os.path.join(baseDirectory, 'cells_heatmap_vox15.tif'))
heatmap[outside] = 0;
io.writeData(os.path.join(baseDirectory, sampleName + '_' + region + '_isolated.tif'), heatmap)
#convert sagittal to coronal
io.writeData(os.path.join(baseDirectory, sampleName + '_' + region + '_isolated_coronal.tif'), rsp.sagittalToCoronalData(os.path.join(baseDirectory, sampleName + '_' + region + '_isolated.tif')));