forked from Cephla-Lab/Squid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
187 lines (171 loc) · 7.76 KB
/
setup.sh
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
# increase swap for cellprofiler stuff which just hangs silently forver when it runs out of memory
sudo fallocate -l 32G /swapfile32g
sudo chmod 600 /swapfile32g
sudo mkswap /swapfile32g
sudo swapon /swapfile32g
echo 'echo -e "/swapfile32g swap swap defaults 0 0\n" >> /etc/fstab' > temp_turn_on_large_swap.sh
sudo bash temp_turn_on_large_swap.sh
rm temp_turn_on_large_swap.sh
# installing prerequisite software packages
sudo usermod -aG dialout $USER # allow communication with arduino boards without superuser access
sudo apt update
sudo apt install -y tree curl git htop xclip # basic tools that should be installed
sudo apt install -y plasma-desktop konsole plasma-nm kde-spectacle # install different desktop environment that does not have broken cellprofiler iccon problems
sudo apt install -y python3-pip python3-pyqtgraph python3-pyqt5 # squid software dependencies
sudo apt install -y libreoffice virtualenv make gcc build-essential libgtk-3-dev openjdk-11-jdk-headless default-libmysqlclient-dev libnotify-dev libsdl2-dev # dependencies for cellprofiler
sudo snap install --classic code # install visual studio code
# set environmental variables required for cellprofiler installation
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$PATH:/home/ubuntu/.local/bin
# install everything relative to home
cd ~
# install micro, a great terminal text editor (from .deb file instead of apt repo because the version in apt creates a trash log.txt file in wd whenever the editor is opened)
wget https://github.com/zyedidia/micro/releases/download/v2.0.11/micro-2.0.11-amd64.deb
sudo dpkg -i micro-2.0.11-amd64.deb
# setup microscope python env (which is global env, since Qt is used for gui, which does not work inside virtualenv)
pip3 install --upgrade setuptools pip
# python dependencies for squid software (PyQt5 might not actually be required? seems like it is already installed via python3-pyqt5, same for pyqtgraph)
pip3 install imagecodecs==2023.1.23 Pillow==9.3.* PyQt5==5.14.* pyqtgraph==0.12.* QtPy==2.2.* scipy==1.9.* numpy==1.23.* flask matplotlib pyserial pandas imageio opencv-python opencv-contrib-python lxml crc==1.2.0 scikit-image tqdm
# install orange
virtualenv orange_venv
source orange_venv/bin/activate
pip3 install --upgrade setuptools pip
pip3 install PyQt5 numpy==1.24
pip3 install orange3
deactivate
# install cellprofiler
virtualenv cellprofiler_venv
source cellprofiler_venv/bin/activate
pip3 install numpy==1.24 matplotlib qtpy pyserial pandas imageio opencv-python opencv-contrib-python lxml crc # python dependencies for squid software, installed into cellprofiler virtualenv
# download prebuilt wxpython wheel to avoid local compilation which takes 30 minutes
wget https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04/wxPython-4.1.0-cp38-cp38-linux_x86_64.whl
pip3 install wxPython-4.1.0-cp38-cp38-linux_x86_64.whl
pip3 install cellprofiler==4.2.6 # numpy needs to be done installing before cellprofiler is installed
deactivate
# install cellprofiler analyst
virtualenv cellprofileranalyst_venv
source cellprofileranalyst_venv/bin/activate
pip3 install numpy==1.23 pandas seaborn scikit-learn verlib python-javabridge python-bioformats
pip3 install wxPython-4.1.0-cp38-cp38-linux_x86_64.whl
wget https://github.com/CellProfiler/CellProfiler-Analyst/archive/refs/tags/3.0.4.tar.gz -O cpa304.tar.gz
tar -xf cpa304.tar.gz
pip3 install ./CellProfiler-Analyst-3.0.4
# for some reason these icons are not copied during installation (which crashes the program on startup)
cp CellProfiler-Analyst-3.0.4/cpa/icons/* cellprofileranalyst_venv/lib/python3.8/site-packages/cpa/icons/
deactivate
# install microscope software (and firmware)
cd ~/Downloads
git clone https://github.com/pharmbio/squid # download squid software and firmware repo
cd squid/software
cp reference_machine_config.json machine_config.json
cd ~
# from https://forum.squid-imaging.org/t/setting-up-arduino-teensyduino-ide-for-uploading-firmware/36 :
# download arduino IDE
curl https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz -o arduino-1.8.19.tar.xz
tar -xf arduino-1.8.19.tar.xz
# install arduino udev rules for arduino board communication
curl https://www.pjrc.com/teensy/00-teensy.rules -o 00-teensy.rules
sudo cp 00-teensy.rules /etc/udev/rules.d/
# install teensyduino board package (teensy4.1 is used inside the microscopes)
curl https://www.pjrc.com/teensy/td_157/TeensyduinoInstall.linux64 -o teensyduino-install.linux64
chmod +x teensyduino-install.linux64
./teensyduino-install.linux64 --dir=arduino-1.8.19
cd arduino-1.8.19
# install arduino IDE (incl. teensyduin)
chmod +x install.sh
sudo ./install.sh
# install/upgrade microscope firmware
echo "manual instructions: in the now open window, manually comment #include 'def_octopi.h' and uncomment #include 'def_octopi_80120.h', then switch to correct board (teensy 4.1) then install the packages PacketSerial and FastLED (both in Tools), then flash firmware"
cd ~/Downloads/squid/firmware/octopi_firmware_v2/main_controller_teensy41
arduino main_controller_teensy41.ino
# install camera driver
cd ~/Downloads/squid/software/drivers\ and\ libraries/daheng\ camera/Galaxy_Linux-x86_Gige-U3_32bits-64bits_1.2.1911.9122
echo -e "\ny\nEn\n" | sudo ./Galaxy_camera.run
cd ~/Downloads/squid/software/drivers\ and\ libraries/daheng\ camera/Galaxy_Linux_Python_1.0.1905.9081/api
python3 setup.py build
sudo python3 setup.py install
cd # to home directory
# set up bash commands to run installed software
echo '
run_microscope() {
cd ~/Downloads/squid/software
python3 main_hcs.py
}
run_cellprofiler() {
source ~/cellprofiler_venv/bin/activate
python3 -m cellprofiler
deactivate
}
run_cellprofileranalyst() {
source ~/cellprofileranalyst_venv/bin/activate
python3 ~/CellProfiler-Analyst-3.0.4/CellProfiler-Analyst.py
deactivate
}
run_orange() {
source ~/orange_venv/bin/activate
python3 -m Orange.canvas
deactivate
}
' >> ~/.bashrc
source ~/.bashrc
# create scripts to run certain software in their respective environment
echo '#!/bin/bash
source /home/pharmbio/cellprofiler_venv/bin/activate
python3 -m cellprofiler
deactivate
' > ~/Documents/cellprofiler.sh
echo '#!/bin/bash
source /home/pharmbio/cellprofileranalyst_venv/bin/activate
python3 ~/CellProfiler-Analyst-3.0.4/CellProfiler-Analyst.py
deactivate
' > ~/Documents/cellprofileranalyst.sh
echo '#!/bin/bash
cd /home/pharmbio/Downloads/squid/software
python3 main_hcs.py
sleep 10
' > ~/Documents/microscope.sh
echo '#!/bin/bash
source /home/pharmbio/orange_venv/bin/activate
python3 -m Orange.canvas
deactivate
' > ~/Documents/orange.sh
# add desktop icons to start the installed software (incl. microscope)
echo '[Desktop Entry]
Type=Application
Terminal=false
Name=cellprofiler
Icon=utilities-terminal
Exec=/home/pharmbio/Documents/cellprofiler.sh
Categories=Application;
' > ~/Desktop/cellprofiler.desktop
echo '[Desktop Entry]
Type=Application
Terminal=false
Name=cellprofiler analyst
Icon=utilities-terminal
Exec=/home/pharmbio/Documents/cellprofileranalyst.sh
Categories=Application;
' > ~/Desktop/cellprofileranalyst.desktop
echo '[Desktop Entry]
Type=Application
Terminal=true
Name=microscope
Icon=utilities-terminal
Exec=/home/pharmbio/Documents/microscope.sh
Categories=Application;
' > ~/Desktop/microscope.desktop
echo '[Desktop Entry]
Type=Application
Terminal=false
Name=orange
Icon=utilities-terminal
Exec=/home/pharmbio/Documents/orange.sh
Categories=Application;
' > ~/Desktop/orange.desktop
chmod 755 ~/Desktop/orange.desktop ~/Documents/orange.sh
chmod 755 ~/Desktop/microscope.desktop ~/Documents/microscope.sh
chmod 755 ~/Desktop/cellprofiler.desktop ~/Documents/cellprofiler.sh
chmod 755 ~/Desktop/cellprofileranalyst.desktop ~/Documents/cellprofileranalyst.sh
# remove install files
cd
rm teensyduino-install.linux64 00-teensy.rules arduino-1.8.19.tar.xz micro-2.0.11-amd64.deb cpa304.tar.gz wxPython-4.1.0-cp38-cp38-linux_x86_64.whl