Skip to content

Commit

Permalink
adding metrics to parameter scan
Browse files Browse the repository at this point in the history
  • Loading branch information
prismofeverything committed Apr 26, 2022
1 parent b3bda4b commit 7fbf78f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
6 changes: 3 additions & 3 deletions vivarium_models/library/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def run_scan(self):
results = {}
for id, parameter_set in self.parameter_sets.items():
data = self.run_simulation(parameter_set)
metrics = [
metric(data)
for metric in self.metrics]
metrics = {
name: metric(data)
for name, metric in self.metrics.items()}
results[id] = {
'data': data,
'metrics': metrics}
Expand Down
36 changes: 35 additions & 1 deletion vivarium_models/processes/readdy_actin_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,40 @@ def test_scan_readdy():
'arp23_concentration': 20.0},
'states': monomer_data}}

metrics = []
def count_monomers(results):
outcome = list(results.values())[-1]
return len(outcome['monomers']['particles'])

def count_monomer_types(results):
outcome = list(results.values())[-1]
monomer_types = {}

for particle in outcome['monomers']['particles'].values():
type_name = particle['type_name']
if type_name not in monomer_types:
monomer_types[type_name] = 0
monomer_types[type_name] += 1

return monomer_types

def filament_lengths(results):
outcome = list(results.values())[-1]
barbed = None
pointed = None
for particle in outcome['monomers']['particles'].values():
if 'barbed' in particle['type_name']:
barbed = np.array(particle['position'])
elif 'pointed' in particle['type_name']:
pointed = np.array(particle['position'])

difference = barbed - pointed
length = np.linalg.norm(difference)
return length

metrics = {
'count_monomers': count_monomers,
'count_monomer_types': count_monomer_types,
'filament_lengths': filament_lengths}

scan = Scan(
parameters,
Expand All @@ -297,6 +330,7 @@ def test_scan_readdy():
metrics=metrics)

results = scan.run_scan()


import ipdb; ipdb.set_trace()

Expand Down

0 comments on commit 7fbf78f

Please sign in to comment.