From 5c994430ecb7580c79c42e0fa664b98c72b7d07f Mon Sep 17 00:00:00 2001 From: Jenkins Date: Wed, 16 Oct 2024 20:49:19 -0500 Subject: [PATCH] add data_packaging to data --- .../data/data_packaging/__init__.py | 26 +++++++++++++++++++ .../data/data_packaging/data_packaging.py | 20 ++++++++++++++ brainscore_vision/data/data_packaging/test.py | 25 ++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 brainscore_vision/data/data_packaging/__init__.py create mode 100644 brainscore_vision/data/data_packaging/data_packaging.py create mode 100644 brainscore_vision/data/data_packaging/test.py diff --git a/brainscore_vision/data/data_packaging/__init__.py b/brainscore_vision/data/data_packaging/__init__.py new file mode 100644 index 000000000..9b9551602 --- /dev/null +++ b/brainscore_vision/data/data_packaging/__init__.py @@ -0,0 +1,26 @@ + +from brainio.assemblies import NeuronRecordingAssembly +from brainscore_vision import load_stimulus_set +from brainscore_vision import stimulus_set_registry, data_registry +from brainscore_vision.data_helpers.s3 import load_assembly_from_s3, load_stimulus_set_from_s3 + +stimulus_set_registry["IAPS"] = lambda: load_stimulus_set_from_s3( + identifier="IAPS", + bucket="brainio-brainscore", + csv_version_id="I90msPTpsEbRGMSnO.Ll76KOjN1waJMX", + csv_sha1="2e6bcf4bffe5d710ce4c744c4dffdbdae256a333", + zip_version_id="jFh.VNtU39NNFMoyss1fmoRFe9OyNv7x", + zip_sha1="9450121d2ac447a3c370e0b2b2bc2a7d9157480b", + filename_prefix='stimulus_', +) + +data_registry["IAPS"] = lambda: load_assembly_from_s3( + identifier="IAPS", + version_id="J2gDD7VTuZ7qNT.JBfwFL9Z3emgNnRP3", + sha1="9050b94675687b4267031bfa3ae09c70654203dd", + bucket="brainio-brainscore", + cls=NeuronRecordingAssembly, + stimulus_set_loader=lambda: load_stimulus_set('IAPS'), +) + + \ No newline at end of file diff --git a/brainscore_vision/data/data_packaging/data_packaging.py b/brainscore_vision/data/data_packaging/data_packaging.py new file mode 100644 index 000000000..da1d1f425 --- /dev/null +++ b/brainscore_vision/data/data_packaging/data_packaging.py @@ -0,0 +1,20 @@ + +from brainio.packaging import package_stimulus_set, package_data_assembly +from brainscore_vision import load_dataset, load_stimulus_set + +def upload_stimulus_set_to_s3(stimuli): + return package_stimulus_set(catalog_name=None, proto_stimulus_set=stimuli, + stimulus_set_identifier=stimuli.name, bucket_name="brainio-brainscore") + +def upload_assembly_to_s3(assembly): + return package_data_assembly(None, assembly, assembly_identifier=assembly.name, + stimulus_set_identifier=assembly.name, + assembly_class_name="NeuronRecordingAssembly", + bucket_name="brainio-brainscore") + + +if __name__ == '__main__': + ss = load_stimulus_set('IAPS') + assembly = load_dataset('IAPS') + + \ No newline at end of file diff --git a/brainscore_vision/data/data_packaging/test.py b/brainscore_vision/data/data_packaging/test.py new file mode 100644 index 000000000..4e9e9d5b7 --- /dev/null +++ b/brainscore_vision/data/data_packaging/test.py @@ -0,0 +1,25 @@ + +import pytest + +from brainscore_vision import load_dataset, load_stimulus_set +from brainscore_vision.benchmark_helpers import check_standard_format + + +@pytest.mark.memory_intense +@pytest.mark.private_access +def test_assembly(): + assembly = load_dataset('IAPS') + check_standard_format(assembly, nans_expected=True) + assert assembly.attrs['stimulus_set_identifier'] == 'IAPS' + assert set(assembly['region'].values) == {'IT'} + assert len(assembly['presentation']) == 30150 + assert len(assembly['neuroid']) == 36 + # assert len(set(assembly['background_id'].values)) == 121 + + +@pytest.mark.private_access +def test_stimulus_set(): + stimulus_set = load_stimulus_set('IAPS') + assert len(stimulus_set) == 10 + + \ No newline at end of file