diff --git a/.github/labeler.yml b/.github/labeler.yml index 7c88a2069..c2da51c25 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -5,3 +5,7 @@ "Language: Python": - changed-files: - any-glob-to-any-file: '**/*.py' + +"Package: EEG chunker": +- changed-files: + - any-glob-to-any-file: 'python/loris_eeg_chunker/**' diff --git a/install/templates/environment_template b/install/templates/environment_template index 22fe48d36..403c06a83 100644 --- a/install/templates/environment_template +++ b/install/templates/environment_template @@ -6,7 +6,7 @@ source ${MINC_TOOLKIT_DIR}/minc-toolkit-config.sh umask 0002 # export PATH, PERL5LIB, TMPDIR and LORIS_CONFIG variables -export PATH=/opt/${PROJECT}/bin/mri:/opt/${PROJECT}/bin/mri/uploadNeuroDB:/opt/${PROJECT}/bin/mri/uploadNeuroDB/bin:/opt/${PROJECT}/bin/mri/dicom-archive:/opt/${PROJECT}/bin/mri/python/scripts:/opt/${PROJECT}/bin/mri/tools:/opt/${PROJECT}/bin/mri/python/loris_eeg_chunker:${MINC_TOOLKIT_DIR}/bin:/usr/local/bin/tpcclib:$PATH +export PATH=/opt/${PROJECT}/bin/mri:/opt/${PROJECT}/bin/mri/uploadNeuroDB:/opt/${PROJECT}/bin/mri/uploadNeuroDB/bin:/opt/${PROJECT}/bin/mri/dicom-archive:/opt/${PROJECT}/bin/mri/python/scripts:/opt/${PROJECT}/bin/mri/tools:${MINC_TOOLKIT_DIR}/bin:/usr/local/bin/tpcclib:$PATH export PERL5LIB=/opt/${PROJECT}/bin/mri/uploadNeuroDB:/opt/${PROJECT}/bin/mri/dicom-archive:$PERL5LIB export TMPDIR=/tmp export LORIS_CONFIG=/opt/${PROJECT}/bin/mri/config diff --git a/pyproject.toml b/pyproject.toml index 068ac2b6b..07e620b5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,17 +12,13 @@ license-files = ["LICENSE"] requires-python = ">= 3.11" dependencies = [ "boto3==1.35.99", - "google", "mat73", "matplotlib", - "mne", - "mne-bids>=0.14", "mysqlclient", "nibabel", "nilearn", "nose", "numpy", - "protobuf>=3.0.0", "pybids==0.17.0", "pydicom", "python-dateutil", @@ -30,6 +26,7 @@ dependencies = [ "scipy", "sqlalchemy>=2.0.0", "virtualenv", + "loris-eeg-chunker @ {root:uri}/python/loris_eeg_chunker", ] [project.optional-dependencies] @@ -42,10 +39,12 @@ dev = [ [project.urls] Homepage = "https://github.com/aces/loris-mri" +[tool.hatch.metadata] +allow-direct-references = true + [tool.hatch.build.targets.wheel] packages = [ "python/lib", - "python/loris_eeg_chunker", "python/tests", ] diff --git a/python/lib/physiological.py b/python/lib/physiological.py index 97b4f639a..e8dcf7c61 100644 --- a/python/lib/physiological.py +++ b/python/lib/physiological.py @@ -1234,12 +1234,13 @@ def create_chunks_for_visualization(self, physio_file_id, data_dir): # determine which script to run based on the file type file_type = self.grep_file_type_from_file_id(physio_file_id) - if file_type == 'set': - script = os.environ['LORIS_MRI'] + '/python/loris_eeg_chunker/eeglab_to_chunks.py' - command = 'python ' + script + ' ' + full_file_path + ' --destination ' + chunk_root_dir - elif file_type == 'edf': - script = os.environ['LORIS_MRI'] + '/python/loris_eeg_chunker/edf_to_chunks.py' - command = 'python ' + script + ' ' + full_file_path + ' --destination ' + chunk_root_dir + match file_type: + case 'set': + script = 'eeglab-to-chunks' + case 'edf': + script = 'edf-to-chunks' + + command = script + ' ' + full_file_path + ' --destination ' + chunk_root_dir # chunk the electrophysiology dataset if a command was determined above try: diff --git a/python/loris_eeg_chunker/README.md b/python/loris_eeg_chunker/README.md index 4f7046e71..18fd0f892 100644 --- a/python/loris_eeg_chunker/README.md +++ b/python/loris_eeg_chunker/README.md @@ -1,3 +1,5 @@ +# LORIS EEG chunker + Set of scripts to chunk EEG data in smaller bits for the React viewer of LORIS. These scripts were extracted on July 8th, 2019 from the master branch of the diff --git a/python/loris_eeg_chunker/pyproject.toml b/python/loris_eeg_chunker/pyproject.toml index ac31b2e9d..e27726c05 100644 --- a/python/loris_eeg_chunker/pyproject.toml +++ b/python/loris_eeg_chunker/pyproject.toml @@ -1,3 +1,31 @@ +[project] +name = "loris-eeg-chunker" +version = "27.0.0" +description = "The LORIS EEG chunker" +readme = "README.md" +license = "GPL-3.0-or-later" +requires-python = ">= 3.11" +dependencies = [ + "google", + "mne", + "mne-bids>=0.14", + "numpy", + "protobuf>=3.0.0", + "scipy", +] + +[project.scripts] +edf-to-chunks = "loris_eeg_chunker.scripts.edf_to_chunks:main" +eeglab-to-chunks = "loris_eeg_chunker.scripts.eeglab_to_chunks:main" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["src/loris_eeg_chunker"] + [tool.ruff] extend = "../../pyproject.toml" +src = ["src"] exclude = ["protocol_buffers"] diff --git a/python/loris_eeg_chunker/chunking.py b/python/loris_eeg_chunker/src/loris_eeg_chunker/chunking.py similarity index 100% rename from python/loris_eeg_chunker/chunking.py rename to python/loris_eeg_chunker/src/loris_eeg_chunker/chunking.py diff --git a/python/loris_eeg_chunker/protocol_buffers/chunk_pb2.py b/python/loris_eeg_chunker/src/loris_eeg_chunker/protocol_buffers/chunk_pb2.py similarity index 100% rename from python/loris_eeg_chunker/protocol_buffers/chunk_pb2.py rename to python/loris_eeg_chunker/src/loris_eeg_chunker/protocol_buffers/chunk_pb2.py diff --git a/python/loris_eeg_chunker/edf_to_chunks.py b/python/loris_eeg_chunker/src/loris_eeg_chunker/scripts/edf_to_chunks.py similarity index 99% rename from python/loris_eeg_chunker/edf_to_chunks.py rename to python/loris_eeg_chunker/src/loris_eeg_chunker/scripts/edf_to_chunks.py index 6434ae07b..23fb60ca9 100755 --- a/python/loris_eeg_chunker/edf_to_chunks.py +++ b/python/loris_eeg_chunker/src/loris_eeg_chunker/scripts/edf_to_chunks.py @@ -13,7 +13,7 @@ def load_channels(exclude): return lambda path : mne.io.read_raw_edf(path, exclude=exclude, preload=False) -if __name__ == '__main__': +def main(): parser = argparse.ArgumentParser( description='Convert .edf files to chunks for browser based visualisation.') parser.add_argument('files', metavar='FILE', type=str, nargs='+', @@ -87,3 +87,7 @@ def load_channels(exclude): destination=args.destination, prefix=args.prefix ) + + +if __name__ == '__main__': + main() diff --git a/python/loris_eeg_chunker/eeglab_to_chunks.py b/python/loris_eeg_chunker/src/loris_eeg_chunker/scripts/eeglab_to_chunks.py similarity index 99% rename from python/loris_eeg_chunker/eeglab_to_chunks.py rename to python/loris_eeg_chunker/src/loris_eeg_chunker/scripts/eeglab_to_chunks.py index 902251a23..070478068 100755 --- a/python/loris_eeg_chunker/eeglab_to_chunks.py +++ b/python/loris_eeg_chunker/src/loris_eeg_chunker/scripts/eeglab_to_chunks.py @@ -13,7 +13,7 @@ def load_channels(path): return mne.io.read_raw_eeglab(path, preload=False) -if __name__ == '__main__': +def main(): parser = argparse.ArgumentParser( description='Convert .set files to chunks for browser based visualisation.') parser.add_argument('files', metavar='FILE', type=str, nargs='+', @@ -57,3 +57,7 @@ def load_channels(path): destination=args.destination, prefix=args.prefix ) + + +if __name__ == '__main__': + main() diff --git a/test/mri.Dockerfile b/test/mri.Dockerfile index 683ce94e7..f5803f16d 100644 --- a/test/mri.Dockerfile +++ b/test/mri.Dockerfile @@ -86,7 +86,7 @@ RUN bash ./test/imaging_install_test.sh $DATABASE_NAME $DATABASE_USER $DATABASE_ # Setup the LORIS-MRI environment variables ENV PROJECT=loris ENV MINC_TOOLKIT_DIR=/opt/minc/1.9.18 -ENV PATH=/opt/${PROJECT}/bin/mri:/opt/${PROJECT}/bin/mri/uploadNeuroDB:/opt/${PROJECT}/bin/mri/uploadNeuroDB/bin:/opt/${PROJECT}/bin/mri/dicom-archive:/opt/${PROJECT}/bin/mri/python/scripts:/opt/${PROJECT}/bin/mri/tools:/opt/${PROJECT}/bin/mri/python/loris_eeg_chunker:${MINC_TOOLKIT_DIR}/bin:/usr/local/bin/tpcclib:$PATH +ENV PATH=/opt/${PROJECT}/bin/mri:/opt/${PROJECT}/bin/mri/uploadNeuroDB:/opt/${PROJECT}/bin/mri/uploadNeuroDB/bin:/opt/${PROJECT}/bin/mri/dicom-archive:/opt/${PROJECT}/bin/mri/python/scripts:/opt/${PROJECT}/bin/mri/tools:${MINC_TOOLKIT_DIR}/bin:/usr/local/bin/tpcclib:$PATH ENV PERL5LIB=/opt/${PROJECT}/bin/mri/uploadNeuroDB:/opt/${PROJECT}/bin/mri/dicom-archive:$PERL5LIB ENV TMPDIR=/tmp ENV LORIS_CONFIG=/opt/${PROJECT}/bin/mri/config