nion-software / niondata Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
This mechanism could be used during acquisition and after canceled long operations. Processing functions could apply only to the valid portion.
The current implementation uses the default data_descriptor from DataAndMetadata for the result of concatenate. This can lead to unexpected result when concatenating e.g. two sequences, because the result would then be a collection (which is the default behavior of DataAndMetadata).
To decide which data_descriptor to use there are two options:
Use the data_descriptor of the first input xdata. This would match the current behavior for intensity_calibration
Only allow concatenation of xdata with homogeneous data_descriptors and use the common data_descriptor.
The second method would be "cleaner" but is also more restrictive and could cause some confusion for users. On the other hand, concatenating non-homogeneous data is not a well-defined operation so it should maybe not be allowed.
'reshape', for instance
Add tests.
The DataAndMetadata object includes the ability to describe the data type, dimensional usage, and calibrations. But there is no mechanism to track the overall nature of the data array such as whether complex data is Hermitian.
See nion-software/nionswift#242
The Hermitian-ness of the data can be determined programmatically, but it would be time consuming. So having some mechanism of tracking it would be useful.
Also, it might be nice to treat Hermitian-ness as a data type (i.e. complex64-hermitian) but this might be difficult to support when transparently masquerading as an ndarray
since ndarray
has no such data type.
Storing this as a property in metadata would be another possibility. But two things make this difficult: the first is the abstract design idea that the metadata is not descriptive of the data mechanics; the second is that metadata is stripped during any processing (this behavior is currently being debated; but that's how it works right now).
That leaves adding another descriptive element to DataAndMetadata to describe whether complex data is to be considered Hermitian.
Are there other similar descriptive possibilities other than Hermitian?
Multiplying a calibrated image by an uncalibrated image should result in a calibrated image.
BPS email 2021-09-01
Right now, some of them at least try to add some sensible dimensional and intensity calibrations to the output data. But all functions in Core.py
strip the metadata
dict from their inputs.
Processing functions with one input and one output should just copy the metdata to their outputs.
For processing functions with multiple inputs, I'm not sure what the best solution would be. 3 ideas:
quality, offset = xd.register_template(img, tmpl_img)
offset = Geometry.FloatPoint(y=img.data_shape[0] * 0.5 - offset[0], x=img.data_shape[1] * 0.5 - offset[1])
I have an issue related to sequences of color images. A minimal reproducible example, that can be typed into the console, is given below.
data = (numpy.random.rand(4, 64, 64, 3) * 255).astype(np.uint8)
data_descriptor = api.create_data_descriptor(is_sequence=True, collection_dimension_count=0, datum_dimension_count=2)
xdata = api.create_data_and_metadata(data, data_descriptor=data_descriptor)
api.library.create_data_item_from_data_and_metadata(xdata)
—— error message (shortened) ——
dimensional_calibration = data_and_metadata.dimensional_calibrations[dimensional_calibration_index]
IndexError: list index out of range
A simple change to the function “function_data_slice” in nion.data.DataAndMetadata.py makes color sequences work. However, this change currently messes up 1d data.
======================================================================
FAIL: test_function_measure_multi_dimensional_shifts_3d (test.MultiDimensionalProcessing_test.TestMultiDimensionalProcessing) [Test for a 2D collection of 1D data, measure shift of data dimensions along collection axis]
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:\a\niondata\niondata\nion\data\test\MultiDimensionalProcessing_test.py", line 1[8](https://github.com/nion-software/niondata/actions/runs/3049104430/jobs/4914843216#step:8:9)5, in test_function_measure_multi_dimensional_shifts_3d
self.assertTrue(numpy.allclose(result.data, -1.0 * (shifts - shifts[numpy.unravel_index(reference_index, shifts.shape)]), atol=0.5))
AssertionError: False is not true
----------------------------------------------------------------------
Ran 106 tests in 1.34[9](https://github.com/nion-software/niondata/actions/runs/3049104430/jobs/4914843216#step:8:10)s
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.