taigatakano commited on
Commit
e70b1cc
·
1 Parent(s): 21c1270

fix bug and refactor code

Browse files
Files changed (3) hide show
  1. app.py +2 -10
  2. lab_tools/spectrogram.py +68 -66
  3. run_dev_env.sh +10 -3
app.py CHANGED
@@ -58,13 +58,6 @@ with gr.Blocks() as main_ui:
58
  start_time = gr.Slider(minimum=0, maximum=60, value=0.0, step=0.5, label="Start Time (sec)")
59
  end_time = gr.Slider(minimum=0, maximum=60, value=60.0, step=0.5, label="End Time (sec)")
60
 
61
- with gr.Accordion(label="Band Intensityグラフ設定", open=True):
62
- band_intensity_setting = gr.Radio(
63
- ["GAMMA (greater than 30Hz)", "BETA (13-30Hz)", "ALPHA (8-12 Hz)", "THETA (4-8 Hz)", "DELTA (less than 4 Hz)"],
64
- label="使用する周波数帯",
65
- value="THETA (4-8 Hz)",
66
- )
67
-
68
  with gr.Accordion(label="フィルター設定", open=False):
69
  filter_setting = gr.Radio(
70
  ["No Filter", "High PASS", "Low PASS"],
@@ -105,14 +98,13 @@ with gr.Blocks() as main_ui:
105
  config_file = gr.File(label="Ziped Analyze File")
106
  wavelet_image = gr.Image(type="filepath", label="Spectrogram")
107
  band_intensity = gr.Image(type="filepath", label="Band Intensity")
108
- signal_image = gr.Image(type="filepath", label="Signal")
109
 
110
  submit_button.click(spectrogram.generate_spectrogram_and_signal_plot, inputs=[
111
  file_input, analysis_method,
112
  fs_slider, fmax_slider, column_dropdown, start_time, end_time,
113
- filter_setting, fp_hp, fs_hp, gpass, gstop, band_intensity_setting,
114
  integration_method, segment_length, overlap, fontsize],
115
- outputs=[wavelet_image, band_intensity, signal_image, config_file])
116
 
117
  with gr.Tab("1f noise analyze"):
118
  with gr.Row():
 
58
  start_time = gr.Slider(minimum=0, maximum=60, value=0.0, step=0.5, label="Start Time (sec)")
59
  end_time = gr.Slider(minimum=0, maximum=60, value=60.0, step=0.5, label="End Time (sec)")
60
 
 
 
 
 
 
 
 
61
  with gr.Accordion(label="フィルター設定", open=False):
62
  filter_setting = gr.Radio(
63
  ["No Filter", "High PASS", "Low PASS"],
 
98
  config_file = gr.File(label="Ziped Analyze File")
99
  wavelet_image = gr.Image(type="filepath", label="Spectrogram")
100
  band_intensity = gr.Image(type="filepath", label="Band Intensity")
 
101
 
102
  submit_button.click(spectrogram.generate_spectrogram_and_signal_plot, inputs=[
103
  file_input, analysis_method,
104
  fs_slider, fmax_slider, column_dropdown, start_time, end_time,
105
+ filter_setting, fp_hp, fs_hp, gpass, gstop,
106
  integration_method, segment_length, overlap, fontsize],
107
+ outputs=[wavelet_image, band_intensity, config_file])
108
 
109
  with gr.Tab("1f noise analyze"):
110
  with gr.Row():
lab_tools/spectrogram.py CHANGED
@@ -99,19 +99,18 @@ def plot_stft_spectrogram(amplitude, frequencies, times, max_frequency=None, fon
99
  ax.tick_params(axis='both', which='major', labelsize=fontsize)
100
 
101
 
102
- def plot_signal(signal_data, time_data, start_time, end_time, fontsize, window_size=50):
103
- smoothed_signal = np.convolve(signal_data, np.ones(window_size) / window_size, mode='valid')
104
- trimmed_time_array = time_data[:len(smoothed_signal)]
105
- plt.subplots(figsize=(12, 6))
106
- plt.plot(trimmed_time_array, smoothed_signal)
107
- plt.xlim(start_time, end_time)
108
- plt.xlabel("Time [sec]", fontsize=fontsize)
109
- plt.ylabel("Voltage [uV]", fontsize=fontsize)
110
- plt.tick_params(axis='both', which='major', labelsize=fontsize)
111
 
112
 
113
  def calculate_frequency_band_intensity(
114
- frequency_array, analysis_matrix, freq_band, window_size=10, method="STFT", integration_method="simps"):
115
  """
116
  特定の周波数帯域の積分値を0〜36Hzの積分値で正規化した比率を計算する関数
117
 
@@ -125,17 +124,6 @@ def calculate_frequency_band_intensity(
125
  Returns:
126
  band_intensity_ratio (np.ndarray): 指定周波数帯域の強度の時間変化 (0〜36Hz の積分値で正規化)
127
  """
128
- # 全帯域 (0〜36Hz) のインデックス範囲を取得
129
- total_freq_band = (0, 36)
130
- total_start, total_end = total_freq_band
131
- if method == "STFT":
132
- total_indices = np.where((frequency_array >= total_start) & (frequency_array <= total_end))[0]
133
- total_values = frequency_array[total_indices]
134
- elif method == "CWT":
135
- total_indices = range(total_start, total_end + 1)
136
- total_values = np.arange(total_start, total_end + 1) # 仮の周波数配列
137
- else:
138
- raise ValueError("Invalid method. Use 'STFT' or 'CWT'.")
139
 
140
  # 指定した周波数帯域のインデックス範囲を取得
141
  freq_start, freq_end = freq_band
@@ -149,47 +137,68 @@ def calculate_frequency_band_intensity(
149
  raise ValueError("Invalid method. Use 'STFT' or 'CWT'.")
150
 
151
  # 全帯域 (0〜36Hz) の解析データと指定帯域の解析データを抽出
152
- total_matrix = analysis_matrix[total_indices, :]
153
  selected_matrix = analysis_matrix[freq_indices, :]
154
 
155
  # 積分の実行
156
  if integration_method == "trapz":
157
- total_intensity = trapezoid(total_matrix, x=total_values, axis=0)
158
  band_intensity = trapezoid(selected_matrix, x=freq_values, axis=0)
159
  elif integration_method == "simps":
160
- total_intensity = simpson(total_matrix, x=total_values, axis=0)
161
  band_intensity = simpson(selected_matrix, x=freq_values, axis=0)
162
  else:
163
  raise ValueError("Invalid integration method. Use 'trapz' or 'simps'.")
164
 
165
  # 比率を計算
166
- band_intensity_ratio = band_intensity / total_intensity
167
- smoothed_band_intensity_ratio = np.convolve(band_intensity_ratio, np.ones(window_size) / window_size, mode='valid')
168
- smoothed_band_intensity = np.convolve(band_intensity_ratio, np.ones(window_size) / window_size, mode='valid')
 
 
 
169
 
170
- return smoothed_band_intensity_ratio, band_intensity_ratio, band_intensity, smoothed_band_intensity
171
 
 
172
 
173
- def plot_frequency_band_intensity(
174
- time_array, band_intensity, fontsize=12):
175
- """
176
- 特定の周波数帯の強度変化をプロットする関数
177
 
178
- Parameters:
179
- time_array (np.ndarray): 時間配列
180
- band_intensity (np.ndarray): 指定周波数帯域の強度の時間変化
181
- freq_band (tuple): 表示する周波数帯 (例: (10, 20))
182
- fontsize (int): プロットのフォントサイズ
183
- """
184
- trimmed_time_array = time_array[:len(band_intensity)]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  plt.figure(figsize=(12, 6))
186
- plt.plot(trimmed_time_array, band_intensity)
187
- plt.xlabel("Time [sec]", fontsize=fontsize)
188
- plt.ylabel("Integrated Power", fontsize=fontsize)
 
 
 
 
 
 
 
 
 
 
189
  plt.ylim(0.0, 1.0)
190
  plt.xlim(0.0, trimmed_time_array[len(trimmed_time_array) - 1])
191
- plt.grid()
192
- plt.tick_params(axis='both', which='major', labelsize=fontsize)
193
 
194
 
195
  def save_all_data_to_csv(
@@ -207,11 +216,11 @@ def save_all_data_to_csv(
207
  integration_method (str): 数値積分の手法 ("trapz" または "simps")
208
  """
209
  # 各帯域の強度を計算
210
- _, _, gamma_raw, gamma_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (30, 36), method=method, integration_method=integration_method)
211
- _, _, beta_raw, beta_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (15, 30), method=method, integration_method=integration_method)
212
- _, _, alpha_raw, alpha_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (8, 12), method=method, integration_method=integration_method)
213
- _, _, theta_raw, theta_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (4, 8), method=method, integration_method=integration_method)
214
- _, _, delta_raw, delta_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (0, 4), method=method, integration_method=integration_method)
215
 
216
  # 全体の積分値を計算
217
  total_intensity = gamma_smothed + beta_smothed + alpha_smothed + theta_smothed + delta_smothed
@@ -301,7 +310,7 @@ def export_arguments_to_yaml(
301
  uploaded_file, analysis_method, sample_rate, max_frequency,
302
  signal_column_name, start_time, end_time, filter_type,
303
  highpass_cutoff, stopband_cutoff, passband_ripple, stopband_attenuation,
304
- band_intensity_setting, integration_method, segment_length, overlap,
305
  output_path="arguments.yaml"):
306
  """
307
  generate_spectrogram_and_signal_plotの引数をわかりやすい形式でYAMLに書き出す関数
@@ -332,7 +341,6 @@ def export_arguments_to_yaml(
332
  }
333
  },
334
  "frequency_analysis": {
335
- "band_of_interest": band_intensity_setting, # 強度を解析する周波数帯 (例: Gamma, Beta など)
336
  "integration_method": integration_method, # 数値積分の手法 (Simpson, Trapezoidal など)
337
  },
338
  "stft_settings": {
@@ -340,7 +348,8 @@ def export_arguments_to_yaml(
340
  "overlap_ratio": overlap # セグメントのオーバーラップ率
341
  },
342
  "all_band_intensity_analysis": {
343
- "smoothed_window_size": 10
 
344
  }
345
  }
346
 
@@ -377,7 +386,7 @@ def generate_spectrogram_and_signal_plot(
377
  uploaded_file, analysis_method,
378
  sample_rate, max_frequency, signal_column_name, start_time, end_time,
379
  filter_type, highpass_cutoff, stopband_cutoff, passband_ripple, stopband_attenuation,
380
- band_intensity_setting, integration_method, segment_length, overlap, fontsize):
381
  """
382
  入力パラメータに基づいてスペクトログラムと信号プロットを生成し、結果をファイルに保存する関数。
383
 
@@ -394,7 +403,6 @@ def generate_spectrogram_and_signal_plot(
394
  stopband_cutoff (float): フィルターのストップバンドカットオフ周波数 (Hz)。
395
  passband_ripple (float): パスバンドで許容される最大リップル (dB)。
396
  stopband_attenuation (float): ストップバンドでの最小減衰量 (dB)。
397
- band_intensity_setting (str): 解析対象の周波数帯域 (例: "Gamma", "Beta", "Alpha")。
398
  integration_method (str): 使用する数値積分法 ("simps" または "trapz")。
399
  segment_length (int): STFT用のセグメント長 (サンプル数)。
400
  overlap (float): STFTセグメント間のオーバーラップ率 (0.0 ~ 1.0)。
@@ -475,13 +483,9 @@ def generate_spectrogram_and_signal_plot(
475
  time_array = time_array[start_index:end_index]
476
 
477
  # 信号プロットの保存
478
- window_size = 50
479
- plt.figure(dpi=200)
480
- plot_signal(signal_data, time_array, start_time, end_time, fontsize, window_size)
481
- signal_plot_path = os.path.join(output_dir, "signal_plot.png")
482
- plt.savefig(signal_plot_path)
483
 
484
- freq_start, freq_end = labutils.band_intensity_setting_to_band(band_intensity_setting)
485
  integration_method = labutils.integration_method_to_method(integration_method)
486
  overlap = float(overlap) / 100.0
487
 
@@ -495,8 +499,7 @@ def generate_spectrogram_and_signal_plot(
495
  plt.savefig(spectrogram_plot_path)
496
 
497
  plt.figure(dpi=200)
498
- band_intensity, _, _, _ = calculate_frequency_band_intensity(frequencies, amplitude, (freq_start, freq_end), method="STFT", integration_method=integration_method)
499
- plot_frequency_band_intensity(times, band_intensity, fontsize=fontsize)
500
  plot_frequency_band_intensity_path = os.path.join(output_dir, "band_intensity.png")
501
  plt.savefig(plot_frequency_band_intensity_path)
502
 
@@ -514,8 +517,7 @@ def generate_spectrogram_and_signal_plot(
514
  plt.savefig(spectrogram_plot_path)
515
 
516
  plt.figure(dpi=200)
517
- band_intensity, _, _, _ = calculate_frequency_band_intensity(np.arange(max_frequency), cwt_matrix, (freq_start, freq_end), method="CWT", integration_method=integration_method)
518
- plot_frequency_band_intensity(time_array, band_intensity, fontsize=fontsize)
519
  plot_frequency_band_intensity_path = os.path.join(output_dir, "band_intensity.png")
520
  plt.savefig(plot_frequency_band_intensity_path)
521
 
@@ -532,7 +534,7 @@ def generate_spectrogram_and_signal_plot(
532
  file_basename, analysis_method,
533
  sample_rate, max_frequency, signal_column_name, start_time, end_time,
534
  filter_type, highpass_cutoff, stopband_cutoff, passband_ripple, stopband_attenuation,
535
- band_intensity_setting, integration_method, segment_length, overlap,
536
  config_yaml_path
537
  )
538
 
@@ -540,4 +542,4 @@ def generate_spectrogram_and_signal_plot(
540
  os.remove('/tmp/all_analyze_file.zip')
541
  ziped_file = zip_directory_with_command(output_dir, "/tmp/all_analyze_file.zip")
542
 
543
- return spectrogram_plot_path, plot_frequency_band_intensity_path, signal_plot_path, ziped_file
 
99
  ax.tick_params(axis='both', which='major', labelsize=fontsize)
100
 
101
 
102
+ def save_signal(signal_data, time_data, file_path):
103
+ data = {
104
+ "Time [sec]": time_data,
105
+ "Signal Raw [uV]": signal_data,
106
+ }
107
+ df = pd.DataFrame(data)
108
+
109
+ df.to_csv(file_path, index=False)
 
110
 
111
 
112
  def calculate_frequency_band_intensity(
113
+ frequency_array, analysis_matrix, freq_band, method="STFT", integration_method="simps"):
114
  """
115
  特定の周波数帯域の積分値を0〜36Hzの積分値で正規化した比率を計算する関数
116
 
 
124
  Returns:
125
  band_intensity_ratio (np.ndarray): 指定周波数帯域の強度の時間変化 (0〜36Hz の積分値で正規化)
126
  """
 
 
 
 
 
 
 
 
 
 
 
127
 
128
  # 指定した周波数帯域のインデックス範囲を取得
129
  freq_start, freq_end = freq_band
 
137
  raise ValueError("Invalid method. Use 'STFT' or 'CWT'.")
138
 
139
  # 全帯域 (0〜36Hz) の解析データと指定帯域の解析データを抽出
 
140
  selected_matrix = analysis_matrix[freq_indices, :]
141
 
142
  # 積分の実行
143
  if integration_method == "trapz":
 
144
  band_intensity = trapezoid(selected_matrix, x=freq_values, axis=0)
145
  elif integration_method == "simps":
 
146
  band_intensity = simpson(selected_matrix, x=freq_values, axis=0)
147
  else:
148
  raise ValueError("Invalid integration method. Use 'trapz' or 'simps'.")
149
 
150
  # 比率を計算
151
+ if method == "STFT":
152
+ window_size = 10
153
+ elif method == "CWT":
154
+ window_size = 5000
155
+ else:
156
+ raise ValueError("Invalid method. Use 'STFT' or 'CWT'.")
157
 
158
+ smoothed_band_intensity = np.convolve(band_intensity, np.ones(window_size) / window_size, mode='valid')
159
 
160
+ return band_intensity, smoothed_band_intensity
161
 
 
 
 
 
162
 
163
+ def plot_all_band_intensity(
164
+ time_array, frequency_array, analysis_matrix, method="STFT", integration_method="simps"):
165
+ # 各帯域の強度を計算
166
+ _, gamma_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (30, 36), method=method, integration_method=integration_method)
167
+ _, beta_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (15, 30), method=method, integration_method=integration_method)
168
+ _, alpha_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (8, 12), method=method, integration_method=integration_method)
169
+ _, theta_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (4, 8), method=method, integration_method=integration_method)
170
+ _, delta_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (0, 4), method=method, integration_method=integration_method)
171
+
172
+ # 全体の積分値を計算
173
+ total_intensity = gamma_smothed + beta_smothed + alpha_smothed + theta_smothed + delta_smothed
174
+
175
+ # 各帯域を正規化
176
+ gamma_normalized = gamma_smothed / total_intensity
177
+ beta_normalized = beta_smothed / total_intensity
178
+ alpha_normalized = alpha_smothed / total_intensity
179
+ theta_normalized = theta_smothed / total_intensity
180
+ delta_normalized = delta_smothed / total_intensity
181
+
182
+ # pandas DataFrameにまとめる
183
+ trimmed_time_array = time_array[:len(gamma_smothed)]
184
+
185
  plt.figure(figsize=(12, 6))
186
+ plt.stackplot(
187
+ trimmed_time_array,
188
+ gamma_normalized,
189
+ beta_normalized,
190
+ alpha_normalized,
191
+ theta_normalized,
192
+ delta_normalized,
193
+ labels=["Gamma (30-36 Hz)", "Beta (15-30 Hz)", "Alpha (8-12 Hz)", "Theta (4-8 Hz)", "Delta (0-4 Hz)"],
194
+ colors=["#FF6347", "#FFD700", "#ADFF2F", "#87CEEB", "#6A5ACD"]
195
+ )
196
+ plt.xlabel("Time [sec]")
197
+ plt.ylabel("Normalized Intensity")
198
+ plt.legend(loc="upper right")
199
  plt.ylim(0.0, 1.0)
200
  plt.xlim(0.0, trimmed_time_array[len(trimmed_time_array) - 1])
201
+ plt.tight_layout()
 
202
 
203
 
204
  def save_all_data_to_csv(
 
216
  integration_method (str): 数値積分の手法 ("trapz" または "simps")
217
  """
218
  # 各帯域の強度を計算
219
+ gamma_raw, gamma_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (30, 36), method=method, integration_method=integration_method)
220
+ beta_raw, beta_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (15, 30), method=method, integration_method=integration_method)
221
+ alpha_raw, alpha_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (8, 12), method=method, integration_method=integration_method)
222
+ theta_raw, theta_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (4, 8), method=method, integration_method=integration_method)
223
+ delta_raw, delta_smothed = calculate_frequency_band_intensity(frequency_array, analysis_matrix, (0, 4), method=method, integration_method=integration_method)
224
 
225
  # 全体の積分値を計算
226
  total_intensity = gamma_smothed + beta_smothed + alpha_smothed + theta_smothed + delta_smothed
 
310
  uploaded_file, analysis_method, sample_rate, max_frequency,
311
  signal_column_name, start_time, end_time, filter_type,
312
  highpass_cutoff, stopband_cutoff, passband_ripple, stopband_attenuation,
313
+ integration_method, segment_length, overlap,
314
  output_path="arguments.yaml"):
315
  """
316
  generate_spectrogram_and_signal_plotの引数をわかりやすい形式でYAMLに書き出す関数
 
341
  }
342
  },
343
  "frequency_analysis": {
 
344
  "integration_method": integration_method, # 数値積分の手法 (Simpson, Trapezoidal など)
345
  },
346
  "stft_settings": {
 
348
  "overlap_ratio": overlap # セグメントのオーバーラップ率
349
  },
350
  "all_band_intensity_analysis": {
351
+ "smoothed_window_size_for_stft": 10,
352
+ "smoothed_window_size_for_wavelet": 5000
353
  }
354
  }
355
 
 
386
  uploaded_file, analysis_method,
387
  sample_rate, max_frequency, signal_column_name, start_time, end_time,
388
  filter_type, highpass_cutoff, stopband_cutoff, passband_ripple, stopband_attenuation,
389
+ integration_method, segment_length, overlap, fontsize):
390
  """
391
  入力パラメータに基づいてスペクトログラムと信号プロットを生成し、結果をファイルに保存する関数。
392
 
 
403
  stopband_cutoff (float): フィルターのストップバンドカットオフ周波数 (Hz)。
404
  passband_ripple (float): パスバンドで許容される最大リップル (dB)。
405
  stopband_attenuation (float): ストップバンドでの最小減衰量 (dB)。
 
406
  integration_method (str): 使用する数値積分法 ("simps" または "trapz")。
407
  segment_length (int): STFT用のセグメント長 (サンプル数)。
408
  overlap (float): STFTセグメント間のオーバーラップ率 (0.0 ~ 1.0)。
 
483
  time_array = time_array[start_index:end_index]
484
 
485
  # 信号プロットの保存
486
+ signal_data_path = os.path.join(output_dir, "signal_data.csv")
487
+ save_signal(signal_data, time_array, signal_data_path)
 
 
 
488
 
 
489
  integration_method = labutils.integration_method_to_method(integration_method)
490
  overlap = float(overlap) / 100.0
491
 
 
499
  plt.savefig(spectrogram_plot_path)
500
 
501
  plt.figure(dpi=200)
502
+ plot_all_band_intensity(times, frequencies, amplitude, method="STFT", integration_method=integration_method)
 
503
  plot_frequency_band_intensity_path = os.path.join(output_dir, "band_intensity.png")
504
  plt.savefig(plot_frequency_band_intensity_path)
505
 
 
517
  plt.savefig(spectrogram_plot_path)
518
 
519
  plt.figure(dpi=200)
520
+ plot_all_band_intensity(time_array, np.arange(max_frequency), cwt_matrix, method="CWT", integration_method=integration_method)
 
521
  plot_frequency_band_intensity_path = os.path.join(output_dir, "band_intensity.png")
522
  plt.savefig(plot_frequency_band_intensity_path)
523
 
 
534
  file_basename, analysis_method,
535
  sample_rate, max_frequency, signal_column_name, start_time, end_time,
536
  filter_type, highpass_cutoff, stopband_cutoff, passband_ripple, stopband_attenuation,
537
+ integration_method, segment_length, overlap,
538
  config_yaml_path
539
  )
540
 
 
542
  os.remove('/tmp/all_analyze_file.zip')
543
  ziped_file = zip_directory_with_command(output_dir, "/tmp/all_analyze_file.zip")
544
 
545
+ return spectrogram_plot_path, plot_frequency_band_intensity_path, ziped_file
run_dev_env.sh CHANGED
@@ -4,6 +4,13 @@
4
 
5
  ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6
 
 
 
 
 
 
 
 
7
  # Prevent running as root.
8
  if [[ $(id -u) -eq 0 ]]; then
9
  echo "This script cannot be executed with root privileges."
@@ -31,8 +38,8 @@ PLATFORM="$(uname -m)"
31
 
32
  if [ $PLATFORM = "x86_64" ]; then
33
  echo "x86"
34
- docker pull ghcr.io/moriyalab/lab_tool_dev:latest
35
- docker run -it --rm -v $ROOT:/app -w /app --network host ghcr.io/moriyalab/lab_tool_dev:latest /bin/bash
36
  else
37
- echo "Not Support Platform. Only support x86."
38
  fi
 
4
 
5
  ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6
 
7
+ OS="$(uname)"
8
+
9
+ if [[ $OS == "Darwin" ]]; then
10
+ docker pull ghcr.io/moriyalab/lab_tool:latest
11
+ docker run -it --rm -v $ROOT:/app -w /app -p 7860:7860 ghcr.io/moriyalab/lab_tool_dev:latest /bin/bash
12
+ fi
13
+
14
  # Prevent running as root.
15
  if [[ $(id -u) -eq 0 ]]; then
16
  echo "This script cannot be executed with root privileges."
 
38
 
39
  if [ $PLATFORM = "x86_64" ]; then
40
  echo "x86"
41
+ docker pull ghcr.io/moriyalab/lab_tool:latest
42
+ docker run -it --rm -v $ROOT:/app -w /app -p 7860:7860 ghcr.io/moriyalab/lab_tool_dev:latest /bin/bash
43
  else
44
+ echo "Not Support Platform. Only support Linux x86."
45
  fi