# generate
pm.doGenerate(sim_config_name, 1234)
while pm.isGenerating():
    time.sleep(0.02)

# pick a segment to stimulate on the detailed cell
cth = CellTopologyHelper()
distances_dict = dict(cth.getSegmentDistancesFromRoot(vervaeke_cell_type, dendritic_group))
stim_seg_detailed = random.choice([seg_id for seg_id,dist in distances_dict.items() if 200. < dist < 220.])

# pick a segment to stimulate on the reduced cell
stim_seg_reduced = 6

# map distances of all ancestors of stimulation segment
ancestor_dists = dict(cth.getDistancesFromAncestorSegments(vervaeke_cell_type, stim_seg_detailed))

source_segment_index = 0
source_fraction_along = 0.5
delay = 0.

locs = []
detailed_seg_ids = []

# basic simulation setup
sim_ref = 'da' + timestamp
sim_path = '../simulations/' + sim_ref
project.simulationParameters.setReference(sim_ref)
# pick segment to be stimulated on detailed cell
allowed_segments = [[k for k,v in ancestor_dists.items() if d-2. < v < d+2.] for d in detailed_distance_bounds]
rec_segs_detailed = [stim_seg_detailed] + [random.choice(segs) for segs in allowed_segments] + [0]