Skip to content

Commit

Permalink
Manually revert changes to task cells
Browse files Browse the repository at this point in the history
  • Loading branch information
msschwartz21 committed Aug 18, 2024
1 parent 59c18ea commit 03c0465
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@
#

# %% tags=["task"]
gt_tracks = ... ##### Your code here ####
def read_gt_tracks():
gt_tracks = nx.DiGraph()
### YOUR CODE HERE ###
return gt_tracks

gt_tracks = read_gt_tracks()


# %% tags=["solution"]
Expand Down Expand Up @@ -247,9 +252,13 @@ def nodes_from_segmentation(segmentation: np.ndarray) -> nx.DiGraph:
Returns:
nx.DiGraph: A candidate graph with only nodes.
"""
cand_graph = ...

#### Your code here #####
cand_graph = nx.DiGraph()
print("Extracting nodes from segmentation")
for t in tqdm(range(len(segmentation))):
seg_frame = segmentation[t]
props = skimage.measure.regionprops(seg_frame)
for regionprop in props:
### YOUR CODE HERE ###

return cand_graph

Expand Down Expand Up @@ -438,9 +447,11 @@ def solve_basic_optimization(cand_graph):
Returns:
nx.DiGraph: The networkx digraph with the selected solution tracks
"""
solution_graph = ...

#### Your code here ####
cand_trackgraph = motile.TrackGraph(cand_graph, frame_attribute="t")
solver = motile.Solver(cand_trackgraph)
### YOUR CODE HERE ###
solver.solve()
solution_graph = graph_to_nx(solver.get_selected_subgraph())

return solution_graph

Expand Down Expand Up @@ -696,20 +707,14 @@ def get_metrics(gt_graph, labels, run, results_df):
# </div>

# %% tags=["task"]
drift = np.array([
-10, # Expected movement in y
0 # Expected movement in x
])
drift = ... ### YOUR CODE HERE ###

def add_drift_dist_attr(cand_graph, drift):
for edge in cand_graph.edges():
source, target = edge
source_data = cand_graph.nodes[source]
source_pos = np.array([source_data["x"], source_data["y"]])
target_data = cand_graph.nodes[target]
target_pos = np.array([target_data["x"], target_data["y"]])

drift_dist = ... # Calculate the distance between the expected position after drift and the actual target position
### YOUR CODE HERE ###
# get the location of the endpoints of the edge
# then compute the distance between the expected movement and the actual movement
# and save it in the "drift_dist" attribute (below)
cand_graph.edges[edge]["drift_dist"] = drift_dist

add_drift_dist_attr(cand_graph, drift)
Expand Down

0 comments on commit 03c0465

Please sign in to comment.