Author |
Topic |
|
AKazak
Russia
1205 Posts |
Posted - 08/31/2021 : 10:25:39 AM
|
OriginPro 2022 (64-bit) Beta2 9.9.0.105 Windows 7 SP1 x64
Greetings!
I have a matrix object and need to replace all the speckles with the missing values. My current thought is to use Python in Set Values dialog.
What Python libraries are available in Origin to find speckles? How do I set Matrix cells to missing from Python code?
Thank you.
--- Andrey |
|
YimingChen
1609 Posts |
Posted - 09/01/2021 : 09:36:13 AM
|
See example below to set missing values:
import numpy as np
import originpro as op
aa = np.array([ [1, np.nan, 3], [np.nan, 5, 6] ])
ma=op.new_sheet('m')
ma.from_np(aa)
You will need to find such Python package to handle the data in Python and then bring it into Origin.
James |
Edited by - YimingChen on 09/01/2021 09:36:51 AM |
|
|
AKazak
Russia
1205 Posts |
Posted - 09/01/2021 : 1:53:32 PM
|
quote: Originally posted by YimingChen
See example below to set missing values:
import numpy as np
import originpro as op
aa = np.array([ [1, np.nan, 3], [np.nan, 5, 6] ])
ma=op.new_sheet('m')
ma.from_np(aa)
You will need to find such Python package to handle the data in Python and then bring it into Origin.
James
OK.
How do I get a handle of the existing and currently selected matrix object in Python?
--- Andrey |
|
|
AKazak
Russia
1205 Posts |
Posted - 09/01/2021 : 2:09:16 PM
|
Here is the code I need to use:
from skimage.filters import rank
from skimage.morphology import disk, ball
def remove_outliers(image, radius=2, threshold=50):
footprint_function = disk if image.ndim == 2 else ball
footprint = footprint_function(radius=radius)
median_filtered = rank.median(image, footprint)
outliers = (
(image > median_filtered + threshold)
| (image < median_filtered - threshold)
)
output = np.where(outliers, median_filtered, image)
return output
However, for some unknown reason, I cannot install skimage package. Origin gives me a bunch of red lines and closes the console windows without a prompt.
Can you help me with this, please?
--- Andrey |
|
|
easwar
USA
1964 Posts |
Posted - 09/01/2021 : 4:04:08 PM
|
quote:
However, for some unknown reason, I cannot install skimage package. Origin gives me a bunch of red lines and closes the console windows without a prompt.
Can you help me with this, please?
--- Andrey
Hi Andrey,
If you are using the "Python Packages" dialog to install a package (Origin menu: Connectivity->Python Packages), in that dialog, there is a check box named "Pause output window". If you check that, the command window will stay open for you to read the error messages.
To install scikit image, you need to install the package named: scikit-image
Please try that and see if that succeeds.
In the upcoming 2022 version, we will have methods to get multiframe image from a new image window and process that in Python. I presume you are working with an image stack?
Easwar OriginLab
|
|
|
AKazak
Russia
1205 Posts |
Posted - 09/01/2021 : 11:47:43 PM
|
Dear Easwar,
quote: Originally posted by easwar If you are using the "Python Packages" dialog to install a package (Origin menu: Connectivity->Python Packages), in that dialog, there is a check box named "Pause output window". If you check that, the command window will stay open for you to read the error messages.
To install scikit image, you need to install the package named: scikit-image
Please try that and see if that succeeds.
Done! Please consider implementing an automatic "Pause output window" in case of warnings or errors during installation. Besides it would be useful if one could use just installed Python packages without restart of Origin.
quote: Originally posted by easwar In the upcoming 2022 version, we will have methods to get multiframe image from a new image window and process that in Python. I presume you are working with an image stack?
Currently, I have a matrix object to be processed and plan to use Set values... dialog to paste the Python code.
Can you share an example snippet on processing a data matrix object from the dialog, please?
--- Andrey |
|
|
easwar
USA
1964 Posts |
Posted - 09/02/2021 : 09:24:07 AM
|
Hi Andrey,
Here is a simple example where matrix object2 is set with flipped values from object 1.
Easwar OriginLab
|
|
|
AKazak
Russia
1205 Posts |
Posted - 09/03/2021 : 05:41:29 AM
|
quote: Originally posted by easwar
Hi Andrey,
Here is a simple example where matrix object2 is set with flipped values from object 1.
Easwar OriginLab
Dear Easwar,
I your example above, what does F:Fi stand for?
--- Andrey |
|
|
easwar
USA
1964 Posts |
|
AKazak
Russia
1205 Posts |
|
easwar
USA
1964 Posts |
Posted - 09/04/2021 : 2:00:12 PM
|
Hi Andrey,
You can use the menu "Connectivity->Open Examples.py...". This will open the file in code builder and you will see list of supported types plus several examples.
Easwar |
|
|
AKazak
Russia
1205 Posts |
Posted - 09/08/2021 : 07:03:32 AM
|
quote: Originally posted by easwar
Hi Andrey,
You can use the menu "Connectivity->Open Examples.py...". This will open the file in code builder and you will see list of supported types plus several examples.
Easwar
Thank you for the useful suggestion.
--- Andrey |
|
|
|
Topic |
|
|
|