diff --git a/gui_dev/bun.lockb b/gui_dev/bun.lockb index 1b6429db..d2c2e51a 100755 Binary files a/gui_dev/bun.lockb and b/gui_dev/bun.lockb differ diff --git a/gui_dev/package.json b/gui_dev/package.json index 3e1c3c16..bc63014a 100644 --- a/gui_dev/package.json +++ b/gui_dev/package.json @@ -9,8 +9,8 @@ "preview": "vite preview" }, "dependencies": { - "@emotion/react": "^11.13.3", - "@emotion/styled": "^11.13.0", + "@emotion/react": "^11.13.5", + "@emotion/styled": "^11.13.5", "@mui/icons-material": "latest", "@mui/material": "latest", "cbor-js": "^0.1.0", @@ -29,11 +29,11 @@ "@babel/eslint-parser": "^7.25.9", "@babel/preset-env": "^7.26.0", "@babel/preset-react": "^7.25.9", - "@eslint/compat": "^1.2.2", + "@eslint/compat": "^1.2.3", "@vitejs/plugin-react": "^4.3.3", "@welldone-software/why-did-you-render": "^8.0.3", "babel-plugin-react-compiler": "latest", - "eslint": "^9.14.0", + "eslint": "^9.15.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jsdoc": "^50.5.0", "eslint-plugin-react": "^7.37.2", diff --git a/gui_dev/src/pages/SourceSelection/StreamSelector.jsx b/gui_dev/src/pages/SourceSelection/StreamSelector.jsx index df006b0c..f23f4176 100644 --- a/gui_dev/src/pages/SourceSelection/StreamSelector.jsx +++ b/gui_dev/src/pages/SourceSelection/StreamSelector.jsx @@ -27,16 +27,6 @@ export const StreamSelector = () => { ); const updateStreamParameter = useSessionStore((state) => state.updateStreamParameter); - const setLineNoiseValue = useSessionStore((state) => state.setLineNoiseValue); - const setSamplingRateFeaturesValue = useSessionStore( - (state) => state.setSamplingRateFeaturesValue - ); - const setSamplingRateValue = useSessionStore( - (state) => state.setSamplingRateValue - ); - const setStreamParametersAllValid = useSessionStore( - (state) => state.setStreamParametersAllValid - ); const setSourceType = useSessionStore((state) => state.setSourceType); const validateStreamName = (name) => { @@ -65,13 +55,11 @@ export const StreamSelector = () => { const handleSelectStream = (streamName, sfreq) => { setSelectedStreamName(streamName); - updateStreamParameter('lineNoise', 50); + /* updateStreamParameter('lineNoise', 50);*/ updateStreamParameter('samplingRate', sfreq); - updateStreamParameter('samplingRateFeatures', 10); + /*updateStreamParameter('samplingRateFeatures', 10);*/ updateStreamParameter('allValid', true); - - setIsStreamNameValid(true); }; diff --git a/gui_dev/src/stores/sessionStore.js b/gui_dev/src/stores/sessionStore.js index 855be031..b5919562 100644 --- a/gui_dev/src/stores/sessionStore.js +++ b/gui_dev/src/stores/sessionStore.js @@ -2,7 +2,7 @@ // session information, such as the experiment name, // the data source, stream paramerters, the output files paths, etc -import { createPersistStore } from "@/stores/createStore"; +import { createStore } from "@/stores/createStore"; import { getBackendURL } from "@/utils/getBackendURL"; // Workflow stages enum-like object @@ -13,7 +13,7 @@ export const WorkflowStage = Object.freeze({ VISUALIZATION: Symbol("VISUALIZATION"), }); -export const useSessionStore = createPersistStore("session", (set, get) => ({ +export const useSessionStore = createStore("session", (set, get) => ({ // Sync status syncStatus: "synced", // 'synced', 'syncing', 'error' syncError: null, @@ -48,9 +48,9 @@ export const useSessionStore = createPersistStore("session", (set, get) => ({ streamParameters: { samplingRate: 1000, lineNoise: 50, - samplingRateFeatures: 10, + samplingRateFeatures: 11, allValid: false, - experimentName: "sub", + experimentName: "subject", outputDirectory: "default", }, @@ -107,9 +107,9 @@ export const useSessionStore = createPersistStore("session", (set, get) => ({ // Check that all stream parameters are valid checkStreamParameters: () => { - const { samplingRate, lineNoise, samplingRateFeatures } = get(); + // const { samplingRate, lineNoise, samplingRateFeatures } = get(); set({ - areParametersValid: samplingRate && lineNoise && samplingRateFeatures, + areParametersValid: get().streamParameters.samplingRate && get().streamParameters.lineNoise && get().streamParameters.samplingRateFeatures, }); }, @@ -130,8 +130,8 @@ export const useSessionStore = createPersistStore("session", (set, get) => ({ file_path: get().fileSource.path, sampling_rate_features: get().streamParameters.samplingRateFeatures, line_noise: get().streamParameters.lineNoise, - experimentName: get().streamParameters.experimentName, - outputDirectory: get().streamParameters.outputDirectory, + experiment_name: get().streamParameters.experimentName, + out_dir: get().streamParameters.outputDirectory, }), }); @@ -172,8 +172,8 @@ export const useSessionStore = createPersistStore("session", (set, get) => ({ stream_name: lslSource.availableStreams[0].name, sampling_rate_features: streamParameters.samplingRate, line_noise: streamParameters.lineNoise, - experimentName: streamParameters.experimentName, - outputDirectory: streamParameters.outputDirectory, + experiment_name: streamParameters.experimentName, + out_dir: streamParameters.outputDirectory, }), }); diff --git a/py_neuromodulation/gui/backend/app_backend.py b/py_neuromodulation/gui/backend/app_backend.py index e6c74985..6d6832a3 100644 --- a/py_neuromodulation/gui/backend/app_backend.py +++ b/py_neuromodulation/gui/backend/app_backend.py @@ -188,6 +188,8 @@ async def setup_lsl_stream(data: dict): lsl_stream_name=stream_name, sampling_rate_features=data["sampling_rate_features"], line_noise=data["line_noise"], + out_dir=data["out_dir"], + experiment_name=data["experiment_name"], ) return {"message": f"LSL stream '{stream_name}' setup successfully"} except Exception as e: @@ -205,6 +207,8 @@ async def setup_offline_stream(data: dict): file_path=data["file_path"], line_noise=float(data["line_noise"]), sampling_rate_features=float(data["sampling_rate_features"]), + out_dir=data["out_dir"], + experiment_name=data["experiment_name"], ) return {"message": "Offline stream setup successfully"} except ValueError: diff --git a/py_neuromodulation/gui/backend/app_pynm.py b/py_neuromodulation/gui/backend/app_pynm.py index fb5bf3f4..9a69a2c8 100644 --- a/py_neuromodulation/gui/backend/app_pynm.py +++ b/py_neuromodulation/gui/backend/app_pynm.py @@ -81,8 +81,8 @@ def start_run_function( target=self.stream.run, daemon=True, kwargs={ - "out_dir" : out_dir, - "experiment_name" : experiment_name, + "out_dir" : self.out_dir, + "experiment_name" : self.experiment_name, "stream_handling_queue" : self.stream_handling_queue, "is_stream_lsl" : is_stream_lsl, "stream_lsl_name" : stream_lsl_name, @@ -100,6 +100,8 @@ def setup_lsl_stream( lsl_stream_name: str | None = None, line_noise: float | None = None, sampling_rate_features: float | None = None, + out_dir: str = "", + experiment_name: str = "sub", ): from mne_lsl.lsl import resolve_streams @@ -145,16 +147,21 @@ def setup_lsl_stream( #self.settings: NMSettings = NMSettings(sampling_rate_features=sfreq) self.logger.info("settings setup") break - + if channels.shape[0] == 0: self.logger.error(f"Stream {lsl_stream_name} not found") raise ValueError(f"Stream {lsl_stream_name} not found") + + self.out_dir = out_dir + self.experiment_name = experiment_name def setup_offline_stream( self, file_path: str, line_noise: float | None = None, sampling_rate_features: float | None = None, + out_dir: str = "", + experiment_name: str = "sub", ): data, sfreq, ch_names, ch_types, bads = read_mne_data(file_path) @@ -177,3 +184,5 @@ def setup_offline_stream( sampling_rate_features_hz=sampling_rate_features, ) + self.out_dir = out_dir + self.experiment_name = experiment_name