Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update contour_utils.py #25

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

yajushikhurana
Copy link
Contributor

added get_morphology_PCA function

added get_morphology_PCA function
Using pre-commit and added function description
Returns:
List: PCA values for contours
"""
flat_contour_entire_dataset = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename: all_flat_contours

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it contain and what is its shape?

traj = trajectory_collection.get_trajectory(track_id_num)

# getting cell contours using active shape model
cell_contours = get_cellTool_contour_points(traj, contour_num_points=contour_num_points)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shape of cell_contours?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#time x #contours? comment

Args:
trajectory_collection (obj): trajectory collection of a dataset
contour_num_points (int): number of landmark contour points
trajectory_threshold (int, optional): _description_. Defaults to 1.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is trajectory threshold? threshold of the length of the trajectories? Users can filter via trajectory collection outside of this function. Not need to add and create high coupling logics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you prefer if we create a line of code outside before runing pca?

final_contour = np.hstack(flattened_contour)
flat_contour_entire_dataset.append(final_contour)

countour_entire_dataset = np.concatenate(flat_contour_entire_dataset, axis=0).reshape(-1, 2 * contour_num_points)
Copy link
Member

@dummyindex dummyindex Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

countour_entire_dataset -> all_sctc_contours

FYI
sctc - single cell trajectory collection
sct - single cell trajectory
I will add these conventions to dev details

# getting PCA
pca = PCA(n_components=num_components, svd_solver="full")

pca_entire = pca.fit_transform(countour_entire_dataset)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pca_entire ->transformed_pca_contour_data

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this variable is not used by other parts/return value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually wanted to talk to you more about this. I did talk to Weikang about this and maybe I can explain why he did that here in his main pipeline.

countour_entire_dataset = np.concatenate(flat_contour_entire_dataset, axis=0).reshape(-1, 2 * contour_num_points)

# getting PCA
pca = PCA(n_components=num_components, svd_solver="full")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pca -> _pca_model


pca_individual_list = [
pca.transform(
final_contour.reshape((int(len(final_contour) / (2 * contour_num_points)), 2 * contour_num_points))
Copy link
Member

@dummyindex dummyindex Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make code more readable
E.g. someVar = (int(len(final_contour) / (2 * contour_num_points))
I need to understand the code within 10 seconds of reading.
What is pca_individual list? It can mean a lot of things, e.g. each PCA principle components, contours after PCA transforms for each trajectory, etc. Improve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants