@sjcrh/proteinpaint-server 2.61.1 → 2.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/routes/termdb.config.js +8 -0
- package/routes/termdb.getSampleImages.js +67 -0
- package/src/app.js +1172 -932
- package/src/serverconfig.js +3 -0
- package/utils/plotBrainImaging.py +73 -0
package/src/serverconfig.js
CHANGED
|
@@ -55,6 +55,7 @@ if (!serverconfig.clustalo) serverconfig.clustalo = 'clustalo'
|
|
|
55
55
|
if (!serverconfig.Rscript) serverconfig.Rscript = 'Rscript'
|
|
56
56
|
if (!serverconfig.gfServer) serverconfig.gfServer = 'gfServer'
|
|
57
57
|
if (!serverconfig.gfClient) serverconfig.gfClient = 'gfClient'
|
|
58
|
+
// NOTE: will set other cmd paths that require binpath after it's filled-in below
|
|
58
59
|
|
|
59
60
|
/******************
|
|
60
61
|
APPLY OVERRIDES
|
|
@@ -103,6 +104,8 @@ if (!serverconfig.binpath) {
|
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
}
|
|
107
|
+
// defaults tool paths, for those that require binpath
|
|
108
|
+
if (!serverconfig.plotBrainImaging) serverconfig.plotBrainImaging = `${serverconfig.binpath}/utils/plotBrainImaging.py`
|
|
106
109
|
|
|
107
110
|
if (serverconfig.debugmode) {
|
|
108
111
|
// only apply optional routeSetters in debugmode
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import nibabel as nib # Library for loading data from neuroimaging file formats such as NIfTI
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
import numpy as np
|
|
4
|
+
import sys
|
|
5
|
+
import io
|
|
6
|
+
|
|
7
|
+
if len(sys.argv) <= 1:
|
|
8
|
+
print('python3 '+sys.argv[0]+' <path/to/template/file> <path/to/label/file> indexL indexF, indexT')
|
|
9
|
+
sys.exit(1)
|
|
10
|
+
|
|
11
|
+
templateFile = sys.argv[1]
|
|
12
|
+
labelFile = sys.argv[2]
|
|
13
|
+
|
|
14
|
+
# load data from nifti files
|
|
15
|
+
template = nib.load(templateFile).get_fdata()
|
|
16
|
+
labels = nib.load(labelFile).get_fdata()
|
|
17
|
+
labels = np.ma.masked_where(labels == 0, labels) # Mask labels where they are 0
|
|
18
|
+
|
|
19
|
+
l = int(sys.argv[3]) if len(sys.argv) > 3 else 70
|
|
20
|
+
f = int(sys.argv[4]) if len(sys.argv) > 4 else 110
|
|
21
|
+
t = int(sys.argv[5]) if len(sys.argv) > 5 else 80
|
|
22
|
+
|
|
23
|
+
# extract slices l (left, sagittal), f (front, coronal), t (top, axial) from the template and label data
|
|
24
|
+
left_slice = template[l,:,:]
|
|
25
|
+
front_slice = template[:,f,:]
|
|
26
|
+
top_slice = template[:,:,t]
|
|
27
|
+
|
|
28
|
+
left_label = labels[l,:,:]
|
|
29
|
+
front_label = labels[:,f,:]
|
|
30
|
+
top_label = labels[:,:,t]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# adjust the orientation of the plots by flipping and rotating
|
|
34
|
+
left_slice = np.rot90(left_slice)
|
|
35
|
+
left_label = np.rot90(left_label)
|
|
36
|
+
|
|
37
|
+
front_slice = np.flip(np.rot90(front_slice),axis=1)
|
|
38
|
+
front_label = np.flip(np.rot90(front_label),axis=1)
|
|
39
|
+
|
|
40
|
+
top_slice = np.flip(np.rot90(top_slice),axis=1)
|
|
41
|
+
top_label = np.flip(np.rot90(top_label),axis=1)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# create three subplots for sagittal, coronal and axial plane
|
|
45
|
+
fig, ax = plt.subplots(1, 3)
|
|
46
|
+
vmin = 0
|
|
47
|
+
vmax = 100
|
|
48
|
+
alpha = 0.5
|
|
49
|
+
ax[0].imshow(left_slice, 'gray', filternorm=False, vmin=vmin, vmax=vmax)
|
|
50
|
+
ax[0].imshow(left_label, 'jet', alpha=alpha, filternorm=False,vmin=0,vmax=102)
|
|
51
|
+
ax[0].axis('off')
|
|
52
|
+
ax[0].text(0, 0.5, 'P', fontsize=12, color='white', ha='center', va='center', transform=ax[0].transAxes)
|
|
53
|
+
ax[0].text(0.5, 1, 'S', fontsize=12, color='white', ha='center', va='center', transform=ax[0].transAxes)
|
|
54
|
+
|
|
55
|
+
ax[1].imshow(front_slice, 'gray', filternorm=False, vmin=vmin, vmax=vmax)
|
|
56
|
+
ax[1].imshow(front_label, cmap='jet', alpha=alpha, filternorm=False,vmin=0,vmax=102)
|
|
57
|
+
ax[1].axis('off')
|
|
58
|
+
ax[1].text(0, 0.5, 'R', fontsize=12, color='white', ha='center', va='center', transform=ax[1].transAxes)
|
|
59
|
+
ax[1].text(0.5, 1, 'S', fontsize=12, color='white', ha='center', va='center', transform=ax[1].transAxes)
|
|
60
|
+
|
|
61
|
+
ax[2].imshow(top_slice, 'gray', filternorm=False, vmin=vmin, vmax=vmax)
|
|
62
|
+
ax[2].imshow(top_label, cmap='jet', alpha=alpha, filternorm=False,vmin=0,vmax=102)
|
|
63
|
+
ax[2].axis('off')
|
|
64
|
+
ax[2].text(0, 0.5, 'R', fontsize=12, color='white', ha='center', va='center', transform=ax[2].transAxes)
|
|
65
|
+
ax[2].text(0.5, 1, 'A', fontsize=12, color='white', ha='center', va='center', transform=ax[2].transAxes)
|
|
66
|
+
fig.subplots_adjust(wspace=0, hspace=0)
|
|
67
|
+
|
|
68
|
+
# Output the image data to stdout
|
|
69
|
+
buf = io.BytesIO()
|
|
70
|
+
plt.savefig(buf, format='png', bbox_inches='tight', facecolor='k')
|
|
71
|
+
buf.seek(0)
|
|
72
|
+
sys.stdout.buffer.write(buf.getvalue())
|
|
73
|
+
plt.close()
|