-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessing.py
642 lines (529 loc) · 26.9 KB
/
processing.py
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
import os
import sys
import shutil
from SUM_utils import *
from constants import MATLAB_BIN_PATH, CURRENTS_BUILD_PATH, MESHLABSERVER_PATH
def run_standardization(meshfile, atlaspath, dist, maxslope,
clspacing, skippointsfactor, highslope, bumpcriterion, pvends,
use_seed_selector=False, use_laa_seed=False, visualise=True):
"""Runs standardization on original mesh.
Saves output at the location of the input meshfile.
Arguments:
datapath = full path to mesh file
atlaspath = root path of average mesh and unfold disk
dist = length of PVs to keep
maxslope = anything above this is ostium
clspacing = resample the centerline with this spacing
skippointsfactor = percentage of points to ignore at begining of centerline
highslope = above this slope we start counting as potential ostium location
bumpcriterion = ostium if slope higher than highslope and above bump criterion
pvends = enabe PV ends in vmtkcenterlines
use_laa_seed = enable seed for appendage (True|False)
use_seed_selector = enable selection of seeds (True|False)
visualise = enable visualisation of intermin results (True|False)
"""
fileroot = os.path.dirname(meshfile)
filenameroot = os.path.splitext(os.path.basename(meshfile))[0]
inputfile = os.path.join(fileroot, filenameroot + '.vtk')
outfile = os.path.join(fileroot, filenameroot + '.vtp')
vtk2vtp(inputfile, outfile)
# basic VMTK cleaning
inputfile = os.path.join(fileroot, filenameroot + '.vtp')
surface = vmtksurfacereader(inputfile)
outfile = os.path.join(fileroot, filenameroot + 'kite.vtp')
surface = vmtksurfacekiteremoval(surface)
vmtksurfacewriter(surface, outfile)
surface = cleanpolydata(surface)
if visualise:
visualise_color(surface, surface, 'original')
# save surface as ply
outfile = os.path.join(fileroot, filenameroot + '.ply')
writeply(surface, outfile)
inputfile = os.path.join(fileroot, filenameroot + '.ply')
outfile = os.path.join(fileroot, filenameroot + 'poisson.ply')
currentscript = './poissonOT8_QEC.mlx'
print(currentscript)
os.system(MESHLABSERVER_PATH + ' -i ' + inputfile + ' -o ' + outfile +
' -s ' + currentscript)
inputfile = os.path.join(fileroot, filenameroot + 'poisson.ply')
outfile = os.path.join(fileroot, filenameroot + 'poisson.vtk')
ply2vtk(inputfile, outfile)
# prepare files
inputfile = os.path.join(fileroot, filenameroot + 'poisson.vtk')
inputsurface = readpolydatavtk(inputfile)
inputfile = os.path.join(fileroot, filenameroot + 'poisson.vtp')
writevtp(inputsurface, inputfile)
# compute seeds
inputfile = os.path.join(fileroot, filenameroot + 'poisson.vtk')
outputfile = os.path.join(fileroot, filenameroot + 'seeds.vtp')
surface = readpolydatavtk(inputfile)
if not os.path.exists(outputfile) or use_seed_selector:
select_seeds(surface,
'GTLabels',
outputfile,
visualise,
use_laa_seed)
# prepare seeds
seedsfile = os.path.join(fileroot, filenameroot + 'seeds.vtp')
outseedsfile = os.path.join(fileroot, filenameroot + 'seeds.csv')
if use_laa_seed:
# 36 is laa
multiple_seeds_to_csv_no_mitral(seedsfile,
'GTLabels',
[77, 76, 78, 79, 36],
outseedsfile)
# new pv centerlines no mitral
seedsfile = os.path.join(fileroot,filenameroot + 'seeds.csv')
outfile = os.path.join(fileroot,filenameroot + '_')
pv_centerlines_no_mitral_laa(inputfile,
seedsfile,
outfile,
pvends)
# other settings for clipping
specialvein = 37
specialdistance = 2.0
else:
# no 36 because LAA is not used for centerlines
multiple_seeds_to_csv_no_mitral(seedsfile,
'GTLabels',
[77, 76, 78, 79],
outseedsfile)
# new pv centerlines no mitral
seedsfile = os.path.join(fileroot, filenameroot + 'seeds.csv')
outfile = os.path.join(fileroot, filenameroot + '_')
pv_centerlines_no_mitral(inputfile,
seedsfile,
outfile,
pvends)
# other settings for clipping
specialvein = 0 # disabled
specialdistance = 0 # disabled
# label PVs automatically
inputfile = os.path.join(fileroot, filenameroot + 'poisson.vtp')
outfile = os.path.join(fileroot, filenameroot + '_')
clip_veins_sections(inputfile,
outfile,
clspacing,
maxslope,
skippointsfactor,
highslope,
bumpcriterion,
use_laa_seed,
visualise)
# clip PV end points
sufixfile = os.path.join(fileroot, filenameroot + '_')
inputfile = os.path.join(fileroot, filenameroot + '_autolabels.vtp')
inputsurface = readvtp(inputfile)
stdmesh = clip_vein_endpoint(inputsurface,
sufixfile,
dist,
use_laa_seed,
specialvein,
specialdistance)
stdmesh = fillholes(stdmesh,5)
# save
o_file = os.path.join(fileroot, filenameroot + '_clipped.vtk')
writevtk(stdmesh, o_file)
if visualise:
origmesh = readpolydatavtk(os.path.join(fileroot, filenameroot + '.vtk'))
visualise_default(stdmesh, origmesh, 'standard mesh', 'autolabels', 36, 79)
def run_currents(meshfile, atlaspath, mitralcliptype, pvcliptype,
use_similarity = False, use_laa_seed = False, visualise=True):
"""
Performs elastic registration between two surfaces
Arguments:
meshfile = full path to mesh file
atlaspath = root path of average mesh and unfold disk
mitralcliptype = defines type of mitral clip (manual|auto)
pvcliptype = type of PV clip (short|long)
use_similarity = use similarity transform to initialise mesh registration (True|False)
use_laa_seed = enable seed for appendage (True|False)
visualise = enable visualisation of intermin results (True|False)
"""
exe_root = MATLAB_BIN_PATH + ' -nodesktop -nosplash -batch '
exe_matlab = exe_root + '"cd ' + CURRENTS_BUILD_PATH + '; match2vtks('
fileroot = os.path.dirname(meshfile)
filenameroot = os.path.splitext(os.path.basename(meshfile))[0]
# mitral clip
i_file = os.path.join(fileroot, filenameroot + '.vtk')
surfaceorig = readpolydatavtk(i_file)
s_file = os.path.join(fileroot, filenameroot + '_clipped.vtk')
surface = readpolydatavtk(s_file)
# type of mitral clip
if mitralcliptype == 'manual':
print("Previously defined mitral edge")
surfaceclipped = cylinder_mitral_clip(surface, surfaceorig, visualise)
if mitralcliptype == 'auto':
print("Auto clipping plane")
w=[0.95,0.05,0.0]
o_file = os.path.join(fileroot, filenameroot + '_clipped_mitral')
if use_laa_seed:
# if we labeled the LAA, we can use a plane for mitral clipping
surfaceclipped = find_mitral_plane_pvs(surface, 'autolabels', o_file, 0.35, w, 0)
else:
# otherwise, a cylinder which is contained and will preserve the LAA structure
surfaceclipped = find_mitral_cylinder_pvs(surface, 'autolabels', o_file, 0.35, w, 0)
o_file = os.path.join(fileroot, filenameroot + '_clipped_mitral.vtk')
writevtk(surfaceclipped, o_file)
if visualise:
visualise_color(surfaceclipped, surface, 'mitral clip')
# using clipped for lmk selection
i_file = os.path.join(fileroot, filenameroot + '_clipped_mitral.vtk')
source = readpolydatavtk(i_file)
if pvcliptype == 'short':
avg_file = os.path.join(atlaspath, 'affine_average_clipped_shortpvs.vtp')
else:
avg_file = os.path.join(atlaspath, 'affine_average_clipped_longpvs.vtp')
target = readvtp(avg_file)
# intialise
deformed = initial_transform_pvends(source,
target,
'autolabels',
use_similarity,
use_laa_seed)
# FLIPPING / REVERSING SURFACE NORMALS
o_file = os.path.join(fileroot, filenameroot +'_surf1.ply')
writeply(deformed, o_file)
if True: # Flipping Flag: Set to True in order to flip the normals of the clipped surface
deformed = vmtksurfacenormals(deformed)
o_file = os.path.join(fileroot, filenameroot +'_surf1_reversed.ply')
writeply(deformed, o_file)
o_file = os.path.join(fileroot, filenameroot +'_pvends_mitral_init.vtk')
writevtk(deformed, o_file)
if visualise:
visualise_color(deformed, target, 'initialisation')
if pvcliptype == 'short':
avg_file = os.path.abspath(os.path.join(atlaspath, 'affine_average_clipped_shortpvs.vtk'))
else:
avg_file = os.path.abspath(os.path.join(atlaspath, 'affine_average_clipped_longpvs.vtk'))
i_file = os.path.abspath(os.path.join(fileroot, filenameroot +'_pvends_mitral_init.vtk'))
o_file = os.path.abspath(os.path.join(fileroot, filenameroot +'_pvends_mitral_init_currents'))
# run currents
line = exe_matlab + '\'' + i_file + '\''+ ','
line = line + '\'' + avg_file + '\''+ ',' + '\'' + o_file + '\''+ ',' + '\''
line = line + '1' + '\''+ ',' + '\'0.0001\'); quit;"'
print(line)
os.system('"'+line+'"')
def run_sum(meshfile, atlaspath, pvcliptype, glyphon, restorenans,
arraysource, arraytarget, colormap, value_range, visualise= True):
"""
Computes standardized unfold map
Arguments:
meshfile = full path to mesh file
atlaspath = root path of average mesh and unfold disk
pvcliptype = type of PV clip (short|long)
glyphon = enalbe glyph for point_by_point EP measurements (True|False)
restorenans = restore nan values if previously set to a different value (True|False)
arraysource = original scalar arrayname in scalarfile
arraytarget = new scalar arrayname for output file
colormap = colormap to use for PNG screen shot
value_range = pair with min and max values for colormap scaling
visualise = enables visualition of intermin results (True|False)
"""
print(arraytarget)
fileroot = os.path.dirname(meshfile)
filenameroot = os.path.splitext(os.path.basename(meshfile))[0]
outprefix = os.path.join(fileroot,filenameroot + '_' + arraytarget)
if not glyphon:
# Reload scalar values on stdmeshes
i_file = os.path.join(fileroot, filenameroot + '_clipped_mitral.vtk')
o_file = os.path.join(fileroot, filenameroot + '_clipped_mitral_scalars.vtp')
s_file = meshfile
target = readpolydatavtk(i_file)
source = readpolydatavtk(s_file)
surfproj = vmtksurfaceprojection(target, source)
writevtp(surfproj, o_file)
# Transfer scalar values on registered meshes by pointid
i_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_currents.vtk')
o_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_scalars.vtp')
s_file = os.path.join(fileroot, filenameroot + '_clipped_mitral_scalars.vtp')
surface = readpolydatavtk(i_file)
source = readvtp(s_file)
targetle = transfer_array_by_pointid(source, surface, arraysource, arraytarget)
writevtp(targetle, o_file)
# Transfer scalar values from registered meshes to average mesh
if pvcliptype == 'short':
i_file = os.path.join(atlaspath, 'affine_average_clipped_shortpvs.vtp')
else:
i_file = os.path.join(atlaspath, 'affine_average_clipped_longpvs.vtp')
o_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_on_average.vtp')
s_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_scalars.vtp')
surface = readvtp(i_file)
source = readvtp(s_file)
# any value < 0 will be truncated
sourcenolb = zero_truncate_array(source, arraytarget, 0.)
surfproj = vmtksurfaceprojection(surface, sourcenolb)
writevtp(surfproj, o_file)
if visualise:
visualise_color(source, surface, 'currents')
# Transfer scalar values from average mesh to "unfold" mesh
i_file = os.path.join(atlaspath, 'affine_average_clipped_shortpvs.vtp')
o_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_on_average_unfold.vtp')
s_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_on_average.vtp')
surface = readvtp(i_file)
source = readvtp(s_file)
surfproj = vmtksurfaceprojection(surface, source)
writevtp(surfproj, o_file)
# Transfer scalar values from "unfold" mesh to disk by pointid
i_file = os.path.join(atlaspath, 'disk_basedon3d_regions_new_origin.vtp')
o_file = (outprefix + '_disk_basedon3d.vtp')
s_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_on_average_unfold.vtp')
surface = readvtp(i_file)
source = readvtp(s_file)
targetle = transfer_array_by_pointid(source, surface, arraytarget, arraytarget)
writevtp(targetle, o_file)
i_file = os.path.join(atlaspath, 'disk_uniform_labels_pvs.vtp')
o_file = (outprefix + '_disk_uniform.vtp')
s_file = (outprefix + '_disk_basedon3d.vtp')
surface = readvtp(i_file)
source = readvtp(s_file)
targetle = vmtksurfaceprojection(surface, source)
writevtp(targetle, o_file)
o_file = (outprefix + '_disk_uniform.png')
i_file = os.path.join(atlaspath, 'disk_uniform_edges.vtp')
overlay = readvtp(i_file)
visualise_default_continuous(targetle,
overlay,
arraytarget,
arraytarget,
1,
1,
colormap,
0,
o_file,
arraytarget,
value_range[0],
value_range[1])
if glyphon:
# non continous scalar values
i_file = os.path.join(fileroot, filenameroot + '_clipped_mitral.vtk')
o_file = os.path.join(fileroot, filenameroot + '_clipped_mitral_scalars.vtp')
s_file = meshfile
surface = readpolydatavtk(i_file)
source = readpolydatavtk(s_file)
# since the values are single points, they are easily lost in the vmtkprojection
# solution: visit every non nan value and transfer it to the closest point
if visualise:
visualise_default(surface, surface, arraytarget, 'autolabels', 36, 79)
if restorenans:
source = restore_nan_values(source, arraytarget, 0.0001)
point_map = point_map_dictionary()
surface = project_nan_array(
source,
surface,
arraytarget,
point_map,
'original2std'
)
writevtp(surface, o_file)
# Transfer scalar values on registered meshes by pointid
i_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_currents.vtk')
o_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_scalars.vtp')
s_file = os.path.join(fileroot, filenameroot + '_clipped_mitral_scalars.vtp')
surface = readpolydatavtk(i_file)
source = readvtp(s_file)
if visualise:
visualise_default(surface, surface, arraytarget, 'autolabels', 36, 79)
surface = transfer_array_by_pointid(source, surface, arraytarget, arraytarget)
writevtp(surface, o_file)
# Transfer scalar values from registered meshes to average mesh
if pvcliptype == 'short':
i_file = os.path.join(atlaspath, 'affine_average_clipped_shortpvs.vtp')
else:
i_file = os.path.join(atlaspath, 'affine_average_clipped_longpvs.vtp')
o_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_on_average.vtp')
s_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_scalars.vtp')
surface = readvtp(i_file)
source = readvtp(s_file)
surface = project_nan_array(
source,
surface,
arraytarget,
point_map,
'std2average'
)
writevtp(surface, o_file)
# Transfer scalar values from average mesh to "unfold" mesh
i_file = os.path.join(atlaspath, 'affine_average_clipped_shortpvs.vtp')
o_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_on_average_unfold.vtp')
s_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_on_average.vtp')
surface = readvtp(i_file)
source = readvtp(s_file)
surface = project_nan_array(
source,
surface,
arraytarget,
point_map,
'average2unfold'
)
writevtp(surface, o_file)
# Transfer scalar values from "unfold" mesh to disk by pointid
i_file = os.path.join(atlaspath, 'disk_basedon3d_regions_new_origin.vtp')
o_file = (outprefix + '_disk_basedon3d.vtp')
s_file = os.path.join(fileroot, filenameroot + '_pvends_mitral_init_on_average_unfold.vtp')
surface = readvtp(i_file)
source = readvtp(s_file)
surface = transfer_array_by_pointid(source, surface, arraytarget, arraytarget)
writevtp(surface, o_file)
i_file = os.path.join(atlaspath, 'disk_uniform_labels_pvs.vtp')
s_file = (outprefix + '_disk_basedon3d.vtp')
surface = readvtp(i_file)
source = readvtp(s_file)
# region edges
i_file = os.path.join(atlaspath, 'disk_uniform_edges.vtp')
overlay = readvtp(i_file)
surface = project_nan_array(
source,
surface,
arraytarget
)
# make a glyph for every point a non "nan" value
glyphsize = 0.015
glyph = make_nan_glyph(surface, arraytarget,glyphsize)
o_file = (outprefix + '_disk_uniform_glyph.png')
writevtp(glyph, outprefix + '_disk_uniform_glyph.vtp')
visualise_nan_glyph(surface,
glyph,
overlay,
arraytarget,
arraytarget,
1,
1,
colormap,
0,
o_file,
arraytarget,
value_range[0],
value_range[1])
o_file = (outprefix + '_disk_uniform.vtp')
writevtp(surface, o_file)
# find original2unfold point_map
writepointmap2csv(point_map, outprefix + '_intermediate_point_map.csv')
original2unfold_point_map(point_map)
writepointmap2csv(point_map, outprefix + '_point_map.csv', ['original2unfold'])
def run_quantification(atlaspath, unfolddisktarget, datatype, arraytarget,
colormaptarget, threshold_value, value_range,
paired_unfold_disk='', paired_array='',
paired_colormap='', paired_range=''):
"""
Computes metrics per region (e.g. lesion extent (lge and force)
and average force per segment)
Arguments:
atlaspath = root path of average mesh and unfold disk
unfolddisktarget = full path to target unfold disk (either lge or carto)
datatype = data type to process: force | lge
arraytarget = array to process on target mesh
colormaptarget = colormap for arrayref visualisation
threshold_value = above this value data will be measured for coverage
(to disable use 'NaN').
value_range = pair with min and max values for visulization
paired_unfold_disk = full path to a paired unfold disk (e.g. force).
The edges of the current unfold will be ovarlayed
on the paired unfold disk (NaN | path_to_mesh).
paired_array = array to process on paired unfold
paired_colormap = colormap for paired_array visualisation
paired_range = pair with min and max values for visulization
"""
fileroot = os.path.dirname(unfolddisktarget)
filenameroot = os.path.splitext(os.path.basename(unfolddisktarget))[0]
outtarget = os.path.join (fileroot,filenameroot)
# if a threshold value is provided, any region above that value will be
# used to quantify lesion extent
if threshold_value:
print("Computing coverage of", arraytarget, "above: ", threshold_value)
target = readvtp(unfolddisktarget)
if datatype == 'lge':
print("Running histogram normalisation...")
target = histogram_normalisation(target, arraytarget)
arraysufix='_norm'
else:
print("No histogram normalisation")
arraysufix=''
targetnorm_th= add_threshold_array(target, arraytarget + arraysufix, float(threshold_value))
o_file = os.path.join (fileroot, filenameroot + arraysufix + '.vtp')
writevtp(target, o_file)
# compute edges
thregion = pointthreshold(targetnorm_th, arraytarget + arraysufix + '_th', 1, 1)
overlay = extractboundaryedge(thregion)
o_file = outtarget + arraysufix + '_th_edges.png'
visualise_default_continuous(target,
overlay,
arraytarget + arraysufix,
arraytarget+ arraysufix,
1,
1,
colormaptarget,
0,
o_file, colormaptarget)
if paired_unfold_disk:
# get file root
paired_root = os.path.dirname(paired_unfold_disk)
paired_filename = os.path.splitext(os.path.basename(paired_unfold_disk))[0]
outref = os.path.join (paired_root,paired_filename)
# add current edges onto paired unfold disk
paired = readvtp(paired_unfold_disk)
o_file = outref + '_' + arraytarget + '_edges.png'
print("Saving paired overlay to",o_file)
visualise_default_continuous(paired,
overlay,
paired_array,
paired_array,
1,
1,
paired_colormap,
0,
o_file,
paired_colormap,
paired_range[0],
paired_range[1])
# compute % coverage per region
# add array for results.
target_array = add_cell_array(target, arraytarget + '_per', 0)
# then populate each region with value
target_array = area_coverage(target_array, arraytarget + arraysufix + '_th', arraytarget + '_per')
target_array = circumferential_coverage(target_array, arraytarget + arraysufix + '_th', arraytarget + '_per')
target_array = longitudinal_coverage(target_array, arraytarget + arraysufix + '_th', arraytarget + '_per')
o_file = outtarget + arraysufix + '_per.vtp'
writevtp(target_array, o_file)
# percentage plus regions averlay
i_file = os.path.join(atlaspath, 'disk_uniform_edges.vtp')
edges = readvtp(i_file)
o_file = outtarget + arraysufix + '_per_0_100.png'
visualise_default_continuous(target_array,
edges,
arraytarget + '_per',
arraytarget + '_per',
1,
1,
colormaptarget,
0,
o_file,
'per',
0,
100)
else:
# compute mean value per region
print("Averaging", arraytarget, "per region")
target = readvtp(unfolddisktarget)
target_array = add_cell_array(target, arraytarget + '_mean', 0.)
target_array = mean_value_per_region(target_array,
arraytarget,
arraytarget + '_mean')
o_file = outtarget + '_mean.vtp'
writevtp(target_array, o_file)
# percentage plus regions overlay
i_file = os.path.join(atlaspath, 'disk_uniform_edges.vtp')
edges = readvtp(i_file)
o_file = outtarget + '_mean.png'
visualise_default_continuous(target_array,
edges,
arraytarget + '_mean',
arraytarget + '_mean',
1,
1,
colormaptarget,
0,
o_file,
'mean',
value_range[0],
value_range[1])