magnunor / TEM-diffraction-stuff

0 stars 0 forks source link

How to load TIF images into "Analysis of pixelated STEM data" #1

Open rainagyw opened 5 years ago

rainagyw commented 5 years ago

Hi, I found your "Analysis of pixelated STEM data" code online. However, I am not sure how to load the original tif images obtained from DPC. I have two TIF images, A-C and B-D for one site. I saw there is a "loading data" tab on the left, but I am not sure which function to use and how to load the images in TIF type. Could you please give to some guidance on this? This is a great analysis code, and I hope I will be able to use it. Thank you.

magnunor commented 5 years ago

@rainagyw, do you mean http://pixstem.org/?

If yes, this should work:

import numpy as np
import hyperspy.api as hs
import pixstem.api as ps

shift02 = hs.load("data0.tif")
shift13 = hs.load("data1.tif")
s_dpc = ps.DPCSignal2D(np.stack((shift02, shift13)))
s_dpc.get_color_signal().plot()

More info about the DPC functionality can be found here: http://pixstem.org/analysing_dpc_datasets.html

If you have any more questions, you can post them on the pixStem issue tracker: https://gitlab.com/pixstem/pixstem/issues

rainagyw commented 5 years ago

Hi Magnus, I modify the code as you suggested. However, I still cannot get anything after running the code. Do you know how to solve this?

This is what I got after running the code:

crookshanks-190:code yuwei$ source activate python3

(python3) crookshanks-190:code yuwei$ python DPC_stem2.py

(python3) crookshanks-190:code yuwei$

Thank you.

On Tue, Nov 27, 2018 at 10:12 AM Magnus Nord notifications@github.com wrote:

@rainagyw https://github.com/rainagyw, do you mean http://pixstem.org/?

If yes, this should work:

import numpy as npimport hyperspy.api as hsimport pixstem.api as ps

shift02 = hs.load("data0.tif") shift13 = hs.load("data1.tif") s_dpc = ps.DPCSignal2D(np.stack((shift02, shift13))) s_dpc.get_color_signal().plot()

More info about the DPC functionality can be found here: http://pixstem.org/analysing_dpc_datasets.html

If you have any more questions, you can post them on the pixStem issue tracker: https://gitlab.com/pixstem/pixstem/issues

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/magnunor/TEM-diffraction-stuff/issues/1#issuecomment-442093568, or mute the thread https://github.com/notifications/unsubscribe-auth/ArAA64mNCTkWo50R2Th7YTM73l3GNA9bks5uzVZGgaJpZM4Y1oq7 .

-- Regards, Yuwei Guo

magnunor commented 5 years ago

@rainagyw, you'll have to start it in some kind of interactive python environment. Currently you're just running it in, then discarding the results.

This might work, depending on which packages you have installed:

ipython3 --matplotlib qt

Then in the ipython3 console:

run DPC_stem2.py 

Alternatively you might have to use the Jupyter Notebook interface:

ipython3 notebook

And run the code there in a Python3 notebook

run DPC_stem2.py 
rainagyw commented 5 years ago

Dear Magnus, I tried what you suggested and run the code in ipython3. I can run the code. However, after running, I can only see a Python icon appeared in the Dock of my laptop. I cannot open it. Could you please help me solve this problem? Thanks.

On Thu, Nov 29, 2018 at 3:37 AM Magnus Nord notifications@github.com wrote:

@rainagyw https://github.com/rainagyw, you'll have to start it in some kind of interactive python environment. Currently you're just running it in, then discarding the results.

This might work, depending on which packages you have installed:

ipython3 --matplotlib qt

Then in the ipython3 console:

run DPC_stem2.py

Alternatively you might have to use the Jupyter Notebook interface:

ipython3 notebook

And run the code there in a Python3 notebook

run DPC_stem2.py

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/magnunor/TEM-diffraction-stuff/issues/1#issuecomment-442749957, or mute the thread https://github.com/notifications/unsubscribe-auth/ArAA66oFlJYxSnBumYbAlX3k8a-9uNanks5uz5zWgaJpZM4Y1oq7 .

-- Regards, Yuwei Guo

rainagyw commented 5 years ago

Dear Magnus, I am able to get the plot with get_color_image_with_indicator. Here are a few things that I am confused about. The input data for the code is two DPC images. I have 4 quadrant detector. A, B, C, and D. A and C are opposite to each other and along horizontal direction. B and D opposite to each other and along vertical direction with 0 scan rotation. So I input two images, one is the signal detected by A detector minus the signal detected by C detector, the "A-C" image, the other is the signal detected by B detector minus the signal detected by D detector, the "B-D" image. For the output image I obtained after running the code, it is only one image with a color wheel. The color wheel has continuous color. However, based on the colors on my image, I can only see my whole sample is blue (although some part is a bit darker) and the carbon layer on the TEM grid is green (which should have no ferroelectric domain in carbon). If my understanding is correct, the color on the image indicates that there are electrons being collected by the detector in a particular direction that has the same color on the color wheel. However, my sample should have several ferroelectric domains in one single crystal. So the generated color image does not seem correct. Could you please help me find out whether this is because I input the data wrongly (Do I need to input four images detected by A, B, C, D detectors instead of two after subtraction). Or I understand the function of the

What I need is let the code help me find out the ferroelectric domain and electric direction. I would really appreciate your advice. Thanks.

On Tue, Nov 27, 2018 at 10:12 AM Magnus Nord notifications@github.com wrote:

@rainagyw https://github.com/rainagyw, do you mean http://pixstem.org/?

If yes, this should work:

import numpy as npimport hyperspy.api as hsimport pixstem.api as ps

shift02 = hs.load("data0.tif") shift13 = hs.load("data1.tif") s_dpc = ps.DPCSignal2D(np.stack((shift02, shift13))) s_dpc.get_color_signal().plot()

More info about the DPC functionality can be found here: http://pixstem.org/analysing_dpc_datasets.html

If you have any more questions, you can post them on the pixStem issue tracker: https://gitlab.com/pixstem/pixstem/issues

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/magnunor/TEM-diffraction-stuff/issues/1#issuecomment-442093568, or mute the thread https://github.com/notifications/unsubscribe-auth/ArAA64mNCTkWo50R2Th7YTM73l3GNA9bks5uzVZGgaJpZM4Y1oq7 .

-- Regards, Yuwei Guo

magnunor commented 5 years ago

@rainagyw, the pixStem library isn't really intended to work with segmented DPC detector data. I suggest having a look at Gary Paterson's fpd library instead, which has dedicated functions for this.