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

Selection of data from cluster analysis #375

Closed
maclariz opened this issue Aug 16, 2022 · 6 comments
Closed

Selection of data from cluster analysis #375

maclariz opened this issue Aug 16, 2022 · 6 comments
Labels
documentation Relates to the documentation

Comments

@maclariz
Copy link

Perhaps a silly question, but if you run cluster analysis, get some nice results and split your dataset into a small number of orientations (something that happens for most of my datasets), is there then an easy way to select the raw orientations in each area corresponding to a particular cluster for further analysis?

@hakonanes hakonanes added the documentation Relates to the documentation label Aug 20, 2022
@hakonanes
Copy link
Member

Have you looked at the data selection part of the crystal map tutorial? Your cluster labels in DBSCAN.labels_ can be used to obtain a flat boolean mask to get a subset of a CrystalMap (or orientations) to extract the relevant orientations

# Either of the below operations
ori = xmap[dbscan.labels_ == 1].orientations
ori = xmap.orientations[dbscan.labels_ == 1]

If you've passed only orientations corresponding to one phase to DBSCAN.fit(), you could do

ori = xmap["alpha-Ti"][dbscan.labels_ == 1].orientations

Your use case is quite common, I think, and something we should show in the documentation.

@maclariz
Copy link
Author

Thank you @hakonanes . I will use this.

@hakonanes
Copy link
Member

Great! Please report back if it didn't work as you expected or you found an alternative solution.

I'm reopening this issue as I want us to remember to include an example showing this in the documentation.

@hakonanes hakonanes reopened this Aug 22, 2022
@maclariz
Copy link
Author

Fine. I won't be able to do much with this instantly, and I am about to take 2 1/2 weeks annual leave. But if I could do a slice like this on the data, then this makes constructing pole figures from specific variants with appropriately chosen colours rather easy to do...

@hakonanes
Copy link
Member

But if I could do a slice like this on the data, then this makes constructing pole figures from specific variants with appropriately chosen colours rather easy to do

That is exactly the motivation behind the implementation of CrystalMap.__getitem__() (code, tutorial).

@hakonanes
Copy link
Member

I realize this is covered in the docs already.

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

No branches or pull requests

2 participants