forked from nilesh-patil/python-XTensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXT_duplicate_channel.py
More file actions
76 lines (57 loc) · 2.29 KB
/
XT_duplicate_channel.py
File metadata and controls
76 lines (57 loc) · 2.29 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
# Subtracting Channels
#
# Copyright (C) 2018 Nilesh Patil <nilesh.patil@rochester.edu>, MIT license
#
# <CustomTools>
# <Menu name = "Python plugins">
# <Submenu name = "Channel Mods">
# <Item name="Duplicate Channel" icon="Python" tooltip="Copy one channel and append to the list">
# <Command>PythonXT::XT_duplicate_channel(%i)</Command>
# </Item>
# </Submenu>
# </Menu>
# </CustomTools>
import time
import ImarisLib
import numpy as np
from cvbi.gui import create_window_from_list
from tqdm import tqdm
from sklearn.cluster import KMeans
# Get Clusters at every time point
def XT_duplicate_channel(aImarisId):
vImarisLib = ImarisLib.ImarisLib()
vImaris = vImarisLib.GetApplication(aImarisId)
vDataSet = vImaris.GetDataSet()
print('''
####################################################################################
########################### Extension started ##############################
####################################################################################
''')
time.sleep(2)
nC = vDataSet.GetSizeC()
nT = vDataSet.GetSizeT()
channel_list = range(1, nC+1)
channel_selected = create_window_from_list(channel_list, window_title='Select channel A')
ch_in = np.int64(channel_selected)
ch_in_name = vDataSet.GetChannelName(ch_in-1)
print('Input acquired for channel : '+str(ch_in_name))
time.sleep(2)
ch_out = nC+1
ch_out_name = ch_in_name+' - Duplicate'
vDataSet.SetSizeC(ch_out)
vDataSet.SetChannelName(ch_out - 1, ch_out_name)
print('Selected Channel : '+str(ch_in_name))
time.sleep(5)
for ti in tqdm(range(nT)):
data_channel_list = vDataSet.GetDataVolumeFloats(aIndexC=ch_in-1, aIndexT=ti)
data_channel = np.array(data_channel_list)
data_out = data_channel
data_out_list = data_out.tolist()
vDataSet.SetDataVolumeFloats(aData=data_out_list, aIndexC=ch_out-1, aIndexT=ti)
time.sleep(3)
print('''
####################################################################################
######### Extension finished, wait for 5s to close automatically ###########
####################################################################################
''')
time.sleep(5)