Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move .conda to local and avoid pio kaleido saving due to error on mac #354

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ tensorflow-2.4.1-py3-none-any.whl
!*.env.example

process.lock
.conda/
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
working_dir: /app
volumes:
- .:/app
- ../optinist-docker-volumes/.conda/pkgs:/app/.conda/pkgs

# optinist data outputs directories
- ../optinist-docker-volumes/.snakemake/:/app/.snakemake
Expand Down
10 changes: 5 additions & 5 deletions studio/app/common/dataclass/histogram.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Optional

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.io as pio

from studio.app.common.core.utils.filepath_creater import join_filepath
from studio.app.common.core.utils.json_writer import JsonWriter
Expand Down Expand Up @@ -38,8 +37,9 @@ def output_path(self) -> OutputPath:
return OutputPath(path=self.json_path, type=OutputType.HISTOGRAM)

def save_plot(self, output_dir):
fig = px.histogram(x=self.data[0], nbins=20)
plt.figure()
plt.hist(self.data[0], bins=20)
plot_file = join_filepath([output_dir, f"{self.file_name}.png"])
pio.write_image(fig, plot_file)

plt.savefig(plot_file)
plt.close()
save_thumbnail(plot_file)
10 changes: 5 additions & 5 deletions studio/app/common/dataclass/line.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Optional

import matplotlib.pyplot as plt
import pandas as pd
import plotly.express as px
import plotly.io as pio

from studio.app.common.core.utils.filepath_creater import join_filepath
from studio.app.common.core.utils.json_writer import JsonWriter
Expand Down Expand Up @@ -32,8 +31,9 @@ def output_path(self) -> OutputPath:

def save_plot(self, output_dir):
for i in range(len(self.data)):
fig = px.line(y=self.data[i], x=self.columns)
plt.figure()
plt.plot(self.columns, self.data[i])
plot_file = join_filepath([output_dir, f"{self.file_name}_{i}.png"])
pio.write_image(fig, plot_file)

plt.savefig(plot_file)
plt.close()
save_thumbnail(plot_file)
20 changes: 6 additions & 14 deletions studio/app/common/dataclass/pie.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Optional

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import plotly.io as pio

from studio.app.common.core.utils.filepath_creater import join_filepath
from studio.app.common.core.utils.json_writer import JsonWriter
Expand Down Expand Up @@ -39,17 +38,10 @@ def output_path(self) -> OutputPath:
return OutputPath(path=self.json_path, type=OutputType.PIE)

def save_plot(self, output_dir):
fig = go.Figure(
data=[
go.Pie(
labels=self.columns,
values=self.data[0],
sort=False,
direction="clockwise",
)
]
)
plt.figure(figsize=(8, 8)) # Optional: Adjust the figure size as needed
plt.pie(self.data[0], labels=self.columns, counterclock=False, startangle=90)
plt.axis("equal") # Equal aspect ratio ensures the pie chart is circular.
plot_file = join_filepath([output_dir, f"{self.file_name}.png"])
pio.write_image(fig, plot_file)

plt.savefig(plot_file)
plt.close()
save_thumbnail(plot_file)
26 changes: 16 additions & 10 deletions studio/app/common/dataclass/polar.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Optional

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.io as pio

from studio.app.common.core.utils.filepath_creater import join_filepath
from studio.app.common.core.utils.json_writer import JsonWriter
Expand Down Expand Up @@ -33,14 +33,20 @@ def output_path(self) -> OutputPath:

def save_plot(self, output_dir):
for i in range(len(self.data)):
fig = px.line_polar(
r=self.data[i],
theta=self.columns,
direction="counterclockwise",
start_angle=0,
line_close=True,
# Convert theta to radians
theta = np.linspace(0, 2 * np.pi, len(self.columns))
plt.figure()
ax = plt.subplot(111, polar=True)
ax.plot(theta, self.data[i])
ax.set_theta_direction(-1) # Counterclockwise
ax.set_theta_offset(np.pi / 2.0) # Start angle at 0
ax.plot(
[theta[-1], theta[0]],
[self.data[i][-1], self.data[i][0]],
linestyle="-",
linewidth=2,
)
plot_file = join_filepath([output_dir, f"{self.file_name}_{i}.png"])
pio.write_image(fig, plot_file)

plt.savefig(plot_file)
plt.close()
save_thumbnail(plot_file)
6 changes: 3 additions & 3 deletions studio/app/optinist/microscopes/OIRReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ def _get_image_stacks(self) -> list:
single_plane_buffer = np.ctypeslib.as_array(ctypes_buffer_ptr)

# construct return value (each channel's stack)
result_channels_stacks[channel_no, serial_loops_index] = (
single_plane_buffer
)
result_channels_stacks[
channel_no, serial_loops_index
] = single_plane_buffer
serial_loops_index += 1

frame_manager.release_image_body()
Expand Down
1 change: 1 addition & 0 deletions studio/app/optinist/wrappers/caiman/cnmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def util_download_model_files():
with open(file_path, "wb") as f:
f.write(response.content)


def mm_fun(A: np.ndarray, Y: np.ndarray) -> np.ndarray:
"""
This code is a port of the CaImAn-MATLAB function (mm_fun.m).
Expand Down
1 change: 1 addition & 0 deletions studio/app/optinist/wrappers/caiman/conda/caiman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dependencies:
- scikit-image=0.19.*
- protobuf=3.20.*
- caiman>=1.9.9, <=1.9.12
- matplotlib
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ channels:
- defaults
- conda-forge
dependencies:
- python=3.8
- python=3.9
- cython
- numpy=1.22.*
- scikit-image=0.19.*
- protobuf=3.20.*
- caiman>=1.9.9, <=1.9.12
- matplotlib

# for expdb
- gcc=12
1 change: 1 addition & 0 deletions studio/app/optinist/wrappers/expdb/conda/expdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
- gcc=12
- numpy=1.23
- scipy=1.10
- matplotlib
- pip:
- isx==1.0.*
- pynwb==2.6.0
18 changes: 17 additions & 1 deletion studio/config/docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ RUN mkdir -p /opt/miniforge && \
conda clean -y --tarballs
ENV PATH $PATH:/opt/miniforge/bin

ENV CONDA_ALWAYS_COPY=1

# Setup conda dir
RUN mkdir -p /app/.conda/pkgs \
&& mkdir -p /app/.conda/envs \
&& chown -R optinist:www-data /app/.conda \
&& su optinist -c 'cat > /home/optinist/.condarc << EOF
pkgs_dirs:
- /app/.conda/pkgs
envs_dirs:
- /app/.conda/envs
channels:
- conda-forge
- defaults
channel_priority: flexible
EOF'

# setup cron
RUN ln -snf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && echo "Asia/Tokyo" > /etc/timezone && \
apt-get install --no-install-recommends -y cron rsyslog && \
Expand Down Expand Up @@ -111,4 +128,3 @@ USER optinist
COPY studio/app/optinist/wrappers/caiman/run_download_model_files.sh ./
RUN bash run_download_model_files.sh && rm run_download_model_files.sh
USER root

Loading