-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from AllenNeuralDynamics:bc-refactor-schemas
Refactor calibration models
- Loading branch information
Showing
36 changed files
with
1,155 additions
and
5,434 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,61 +1,69 @@ | ||
from aind_behavior_services.base import get_commit_hash | ||
import datetime | ||
|
||
from aind_behavior_services.session import AindBehaviorSessionModel | ||
from aind_behavior_services.base import get_commit_hash | ||
|
||
from aind_behavior_services.calibration.olfactometer import ( | ||
HarpOlfactometerChannel, | ||
OlfactometerChannelType, | ||
OlfactometerChannel, | ||
OlfactometerChannelConfig, | ||
OlfactometerOperationControl, | ||
OlfactometerCalibrationModel, | ||
ChannelType | ||
OlfactometerCalibrationLogic, | ||
OlfactometerCalibration, OlfactometerCalibrationInput, OlfactometerCalibrationOutput | ||
) | ||
|
||
|
||
channels_config = [ | ||
OlfactometerChannel( | ||
channel_index=HarpOlfactometerChannel.Channel0, channel_type=ChannelType.ODOR, flow_capacity=100 | ||
OlfactometerChannelConfig( | ||
channel_index=OlfactometerChannel.Channel0, | ||
channel_type=OlfactometerChannelType.ODOR, | ||
flow_rate=100, | ||
odorant="Banana", | ||
odorant_dilution=0.1, | ||
), | ||
OlfactometerChannel( | ||
channel_index=HarpOlfactometerChannel.Channel1, channel_type=ChannelType.ODOR, flow_capacity=100 | ||
OlfactometerChannelConfig( | ||
channel_index=OlfactometerChannel.Channel1, | ||
channel_type=OlfactometerChannelType.ODOR, | ||
flow_rate=100, | ||
odorant="Strawberry", | ||
odorant_dilution=0.1, | ||
), | ||
OlfactometerChannel( | ||
channel_index=HarpOlfactometerChannel.Channel2, channel_type=ChannelType.ODOR, flow_capacity=100 | ||
OlfactometerChannelConfig( | ||
channel_index=OlfactometerChannel.Channel2, | ||
channel_type=OlfactometerChannelType.ODOR, | ||
flow_rate=100, | ||
odorant="Apple", | ||
odorant_dilution=0.1, | ||
), | ||
OlfactometerChannel( | ||
channel_index=HarpOlfactometerChannel.Channel3, channel_type=ChannelType.CARRIER, flow_capacity=1000 | ||
OlfactometerChannelConfig( | ||
channel_index=OlfactometerChannel.Channel3, channel_type=OlfactometerChannelType.CARRIER, odorant="Air" | ||
), | ||
] | ||
channels_config = {channel.channel_index: channel for channel in channels_config} | ||
|
||
stimuli_config = [ | ||
OlfactometerChannelConfig(channel_index=HarpOlfactometerChannel.Channel0, odorant="Banana", odorant_dilution=0.1), | ||
OlfactometerChannelConfig(channel_index=HarpOlfactometerChannel.Channel1, odorant="Banana", odorant_dilution=0.1), | ||
OlfactometerChannelConfig(channel_index=HarpOlfactometerChannel.Channel2, odorant="Banana", odorant_dilution=0.1), | ||
] | ||
|
||
stimuli_config = {channel.channel_index: channel for channel in stimuli_config} | ||
channels_config = {channel.channel_index: channel for channel in channels_config} | ||
|
||
calibration = OlfactometerCalibration(input=OlfactometerCalibrationInput(), output=OlfactometerCalibrationOutput()) | ||
|
||
OpControl = OlfactometerOperationControl( | ||
calibration_logic = OlfactometerCalibrationLogic( | ||
channel_config=channels_config, | ||
stimulus_config=stimuli_config, | ||
full_flow_rate=1000, | ||
n_repeats_per_stimulus=10, | ||
time_on=1, | ||
time_off=1, | ||
) | ||
|
||
out_model = OlfactometerCalibrationModel( | ||
operation_control=OpControl, | ||
calibration=None, | ||
calibration_session = AindBehaviorSessionModel( | ||
root_path="C:\\Data", | ||
remote_path=None, | ||
date=datetime.datetime.now(), | ||
allow_dirty_repo=False, | ||
experiment="OlfactometerCalibration", | ||
experiment_version="0.0.0", | ||
subject="Olfactometer", | ||
commit_hash=get_commit_hash() | ||
commit_hash=get_commit_hash(), | ||
) | ||
|
||
with open("local/olfactometer.json", "w") as f: | ||
f.write(out_model.model_dump_json(indent=3)) | ||
seed_path = "local/olfactometer_{suffix}.json" | ||
with open(seed_path.format(suffix="calibration_logic"), "w") as f: | ||
f.write(calibration_logic.model_dump_json(indent=3)) | ||
with open(seed_path.format(suffix="session"), "w") as f: | ||
f.write(calibration_session.model_dump_json(indent=3)) |
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,27 +1,34 @@ | ||
from pathlib import Path | ||
|
||
from aind_behavior_services.calibration.load_cells import LoadCellsCalibrationModel | ||
from aind_behavior_services.calibration.olfactometer import OlfactometerCalibrationModel | ||
from aind_behavior_services.calibration.water_valve import WaterValveCalibrationModel | ||
from aind_behavior_services.calibration.aind_manipulator import AindManipulatorCalibrationModel | ||
from aind_behavior_services.session import AindBehaviorSessionModel | ||
from aind_behavior_services.calibration.load_cells import LoadCellsCalibrationLogic | ||
from aind_behavior_services.calibration.olfactometer import OlfactometerCalibrationLogic | ||
from aind_behavior_services.calibration.water_valve import WaterValveCalibrationLogic | ||
from aind_behavior_services.calibration.aind_manipulator import AindManipulatorCalibrationLogic | ||
from aind_behavior_services.utils import convert_pydantic_to_bonsai | ||
|
||
|
||
SCHEMA_ROOT = Path("./src/DataSchemas/schemas") | ||
EXTENSIONS_ROOT = Path("./src/Extensions/") | ||
NAMESPACE_PREFIX = "AindBehaviorRigCalibration" | ||
|
||
|
||
def main(): | ||
models = { | ||
"olfactometer_calibration": OlfactometerCalibrationModel, | ||
"water_valve_calibration": WaterValveCalibrationModel, | ||
"load_cells_calibration": LoadCellsCalibrationModel, | ||
"aind_manipulator_calibration": AindManipulatorCalibrationModel, | ||
"olfactometer_calibration": OlfactometerCalibrationLogic, | ||
"water_valve_calibration": WaterValveCalibrationLogic, | ||
"load_cells_calibration": LoadCellsCalibrationLogic, | ||
"aind_manipulator_calibration": AindManipulatorCalibrationLogic, | ||
} | ||
convert_pydantic_to_bonsai( | ||
models, schema_path=SCHEMA_ROOT, output_path=EXTENSIONS_ROOT, namespace_prefix=NAMESPACE_PREFIX | ||
) | ||
|
||
core_models = {"aind_behavior_session": AindBehaviorSessionModel} | ||
convert_pydantic_to_bonsai( | ||
core_models, schema_path=SCHEMA_ROOT, output_path=EXTENSIONS_ROOT, namespace_prefix="AindBehaviorServices" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.