This repository was archived by the owner on Mar 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
V1 properties data assemblies and stimulus sets #33
Open
tiagogmarques
wants to merge
9
commits into
brain-score:master
Choose a base branch
from
tiagogmarques:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ba64c59
Added file brainio_contrib/mkgu_packaging/movshon/aperture_correct.py
tiagogmarques c029c0f
Merge branch 'master-base'
tiagogmarques af9c348
Added code to generate assemblies and stimuli related to V1 propertie…
tiagogmarques 840c35e
Merge branch 'master-base'
tiagogmarques 87c2d62
Corrected naming of variables and assemblies according to convention.
tiagogmarques df2eef0
Corrected data assembly naming according to convention.
tiagogmarques 27815d0
Added stimuli for texture properties benchmark
tiagogmarques 86deecc
Corrected typo on variable name of two V1 properties
tiagogmarques ce88bec
- Changed the preferred orientation empirical distribution to account…
tiagogmarques File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
| from marques_utils import gen_sample | ||
| from brainio_collection.packaging import package_data_assembly | ||
| from brainio_base.assemblies import DataAssembly | ||
|
|
||
| DATA_DIR = '/braintree/data2/active/users/tmarques/bs_datasets/or_po_DeValois1982.csv' | ||
| ASSEMBLY_NAME = 'dicarlo.Marques_devalois1982a' | ||
| ORIENTATION_STIM_NAME = 'dicarlo.Marques2020_orientation' | ||
|
|
||
|
|
||
| def collect_data(data_dir): | ||
| devalois1982a = pd.read_csv(data_dir, header=None) | ||
|
|
||
| # Preferred orientation data | ||
| pref_or_hist = np.squeeze(np.fliplr(np.roll(devalois1982a[[1]].values.T, 1))) | ||
| pref_or_bins = np.linspace(-22.5, 157.5, 5) | ||
|
|
||
| pref_or = gen_sample(pref_or_hist, pref_or_bins) | ||
|
|
||
| # Create DataAssembly with single neuronal properties and bin information | ||
| assembly = DataAssembly(pref_or, coords={'neuroid_id': ('neuroid', range(pref_or.shape[0])), | ||
| 'region': ('neuroid', ['V1'] * pref_or.shape[0]), | ||
| 'neuronal_property': ['pref_or']}, | ||
mschrimpf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| dims=['neuroid', 'neuronal_property']) | ||
|
|
||
| assembly.attrs['number_of_trials'] = 20 | ||
|
|
||
| for p in assembly.coords['properties'].values: | ||
| assembly.attrs[p+'_bins'] = eval(p+'_bins') | ||
|
|
||
| return assembly | ||
|
|
||
|
|
||
| def main(): | ||
| assembly = collect_data(DATA_DIR) | ||
| assembly.name = ASSEMBLY_NAME | ||
| print('Packaging assembly') | ||
| package_data_assembly(assembly, assembly_identifier=assembly.name, stimulus_set_identifier=ORIENTATION_STIM_NAME, | ||
| assembly_class='PropertiyAssembly', bucket_name='brainio.dicarlo') | ||
mschrimpf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import os | ||
| import numpy as np | ||
| from mkgu_packaging.dicarlo.marques.marques_stim_common import gen_grating_stim, gen_blank_stim, load_stim_info | ||
| from brainio_collection.packaging import package_stimulus_set | ||
|
|
||
| BLANK_STIM_NAME = 'dicarlo.Marques2020_blank' | ||
| RF_STIM_NAME = 'dicarlo.Marques2020_rf' | ||
mschrimpf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ORIENTATION_STIM_NAME = 'dicarlo.Marques2020_orientation' | ||
| SF_STIM_NAME = 'dicarlo.Marques2020_sf' | ||
mschrimpf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| SIZE_STIM_NAME = 'dicarlo.Marques2020_size' | ||
|
|
||
| DATA_DIR = '/braintree/data2/active/users/tmarques/bs_stimuli' | ||
| DEGREES = 12 | ||
| SIZE_PX = 672 | ||
|
|
||
| ## All parameters | ||
| RF_POS = np.linspace(-2.5, 2.5, 21, endpoint=True) | ||
| STIM_POS = np.array([0.5]) | ||
| RADIUS = np.logspace(-3 + 0.75, 4 - 0.75, 12, endpoint=True, base=2) / 2 | ||
| SF = np.logspace(-1.5 + 0.125, 4 - 0.125, 22, endpoint=True, base=2) | ||
| ORIENTATION = np.linspace(0, 165, 12, endpoint=True) | ||
| PHASE = np.linspace(0, 315, 8, endpoint=True) | ||
|
|
||
| STIM_NAMES = [RF_STIM_NAME, ORIENTATION_STIM_NAME, SF_STIM_NAME, SIZE_STIM_NAME] | ||
|
|
||
| POS_DICT = {RF_STIM_NAME: RF_POS, ORIENTATION_STIM_NAME: STIM_POS, SF_STIM_NAME: STIM_POS, SIZE_STIM_NAME: STIM_POS} | ||
| RADIUS_DICT = {RF_STIM_NAME: np.array([1/6]), ORIENTATION_STIM_NAME: np.array([0.25, 0.5, 1]), | ||
| SF_STIM_NAME: np.array([0.75, 2.25]), SIZE_STIM_NAME: RADIUS} | ||
| SF_DICT = {RF_STIM_NAME: np.array([3]), ORIENTATION_STIM_NAME: np.array([1, 2, 4]), SF_STIM_NAME: SF, | ||
| SIZE_STIM_NAME: np.array([1, 2, 4])} | ||
| ORIENTATION_DICT = {RF_STIM_NAME: ORIENTATION[[0, 3, 6, 9]], ORIENTATION_STIM_NAME: ORIENTATION, | ||
| SF_STIM_NAME: ORIENTATION[[0, 2, 4, 6, 8, 10]], SIZE_STIM_NAME: ORIENTATION[[0, 2, 4, 6, 8, 10]]} | ||
| PHASE_DICT = {RF_STIM_NAME: PHASE[[0, 4]], ORIENTATION_STIM_NAME: PHASE, SF_STIM_NAME: PHASE, SIZE_STIM_NAME: PHASE} | ||
|
|
||
|
|
||
| def main(): | ||
| blank_dir = DATA_DIR + os.sep + BLANK_STIM_NAME | ||
| if not (os.path.isdir(blank_dir)): | ||
| gen_blank_stim(degrees=DEGREES, size_px=448, save_dir=blank_dir) | ||
| stimuli = load_stim_info(BLANK_STIM_NAME, blank_dir) | ||
| print('Packaging stimuli:' + stimuli.identifier) | ||
| package_stimulus_set(stimuli, stimulus_set_identifier=stimuli.identifier, bucket_name='brainio.dicarlo') | ||
|
|
||
| for stim_name in STIM_NAMES: | ||
| stim_dir = DATA_DIR + os.sep + stim_name | ||
| if not (os.path.isdir(stim_dir)): | ||
| gen_grating_stim(degrees=DEGREES, size_px=SIZE_PX, stim_name=stim_name, grat_contrast=[1], | ||
| grat_pos=POS_DICT[stim_name], grat_rad=RADIUS_DICT[stim_name], grat_sf=SF_DICT[stim_name], | ||
| grat_orientation=ORIENTATION_DICT[stim_name], grat_phase=PHASE_DICT[stim_name], | ||
| save_dir=stim_dir) | ||
| stimuli = load_stim_info(stim_name, stim_dir) | ||
| print('Packaging stimuli:' + stimuli.identifier) | ||
| package_stimulus_set(stimuli, stimulus_set_identifier=stimuli.identifier, bucket_name='brainio.dicarlo') | ||
| return | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
|
|
||
| import numpy as np | ||
| from brainio_collection.packaging import package_data_assembly | ||
| import scipy.io as sio | ||
| from brainio_base.assemblies import DataAssembly | ||
|
|
||
| DATA_DIR = '/braintree/data2/active/users/tmarques/bs_datasets/Ringach2002.mat' | ||
| ASSEMBLY_NAME = 'dicarlo.Marques2020_Ringach2002' | ||
mschrimpf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ORIENTATION_STIM_NAME = 'dicarlo.Marques2020_orientation' | ||
| PROPERTY_NAMES = ['baseline', 'maxdc', 'mindc', 'maxac', 'mod_ratio', 'circ_var', 'bandwidth', 'orth_pref_ratio', | ||
| 'or_sel', 'cv_bw_ratio', 'opr_cv_diff', 'opr_bw_ratio'] | ||
mschrimpf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| def collect_data(data_dir): | ||
| ringach2002 = sio.loadmat(data_dir) | ||
| or_data = ringach2002['db'] | ||
|
|
||
| # Response magnitudes | ||
| baseline = or_data['spont'][0, 0].T | ||
| n_neuroids = baseline.shape[0] | ||
|
|
||
| maxdc = or_data['maxdc'][0, 0].T | ||
| mindc = or_data['mindc'][0, 0].T | ||
| maxac = or_data['maxfirst'][0, 0].T | ||
| mod_ratio = maxac / maxdc | ||
|
|
||
| # Orientation tuning properties | ||
| circ_var = or_data['orivar'][0, 0].T | ||
| bandwidth = or_data['bw'][0, 0].T | ||
| bandwidth[bandwidth > 90] = np.nan | ||
| orth_pref_ratio = or_data['po'][0, 0].T | ||
|
|
||
| or_sel = np.ones((n_neuroids, 1)) | ||
| or_sel[np.isnan(bandwidth)] = 0 | ||
|
|
||
| # Orientation tuning properties covariances | ||
| cv_bw_ratio = circ_var / bandwidth | ||
| opr_cv_diff = orth_pref_ratio - circ_var | ||
| opr_bw_ratio = orth_pref_ratio/bandwidth | ||
|
|
||
| # Bins | ||
| maxdc_bins = np.logspace(0, 3, 10, base=10) | ||
| maxac_bins = np.logspace(0, 3, 10, base=10) | ||
| mindc_bins = np.logspace(-1-1/3, 2, 11, base=10) | ||
| baseline_bins = np.logspace(-1-1/3, 2, 11, base=10) | ||
| mod_ratio_bins = np.linspace(0, 2, 11) | ||
|
|
||
| circ_var_bins = np.linspace(0, 1, num=14) | ||
| bandwidth_bins = np.linspace(0, 90, num=18) | ||
| orth_pref_ratio_bins = np.linspace(0, 1, num=14) | ||
| or_sel_bins = np.linspace(0, 1, num=3) | ||
|
|
||
| cv_bw_ratio_bins = np.logspace(-3, 0, num=16, base=10) | ||
| opr_bw_ratio_bins = np.logspace(-3, 0, num=16, base=10) | ||
| opr_cv_diff_bins = np.linspace(-1, 1, num=20) | ||
|
|
||
| # Create DataAssembly with single neuronal properties and bin information | ||
| assembly = np.concatenate((baseline, maxdc, mindc, maxac, mod_ratio, circ_var, bandwidth, orth_pref_ratio, or_sel, | ||
| cv_bw_ratio, opr_cv_diff, opr_bw_ratio), axis=1) | ||
|
|
||
| # Filters neurons with weak responses | ||
| good_neuroids = maxdc > baseline + 5 | ||
| assembly = assembly[np.argwhere(good_neuroids)[:, 0], :] | ||
|
|
||
| assembly = DataAssembly(assembly, coords={'neuroid_id': ('neuroid', range(assembly.shape[0])), | ||
| 'region': ('neuroid', ['V1'] * assembly.shape[0]), | ||
| 'neuronal_property': PROPERTY_NAMES}, | ||
| dims=['neuroid', 'neuronal_property']) | ||
|
|
||
| assembly.attrs['number_of_trials'] = 40 | ||
|
|
||
| for p in assembly.coords['neuronal_property'].values: | ||
| assembly.attrs[p+'_bins'] = eval(p+'_bins') | ||
|
|
||
| return assembly | ||
|
|
||
|
|
||
| def main(): | ||
| assembly = collect_data(DATA_DIR) | ||
| assembly.name = ASSEMBLY_NAME | ||
| print('Packaging assembly') | ||
| package_data_assembly(assembly, assembly_identifier=assembly.name, stimulus_set_identifier=ORIENTATION_STIM_NAME, | ||
| assembly_class='PropertyAssembly', bucket_name='brainio.dicarlo') | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.