materialsinnovation / pymks

Materials Knowledge System in Python
https://pymks.readthedocs.io/
Other
115 stars 77 forks source link

2 point statistics to micro structure reconstruction #583

Open owaisahmad18 opened 1 year ago

owaisahmad18 commented 1 year ago

If i have a 2 point statistics data or 2 point spatial correlation can i reconstruct the micro structure with it using pymks?

alisafi96 commented 1 year ago

I can highly recommend the MCRpy (https://github.com/NEFM-TUDresden/MCRpy) tool for reconstruction problems. It characterizes the microstructure (for instance with 2-point statistics) and performs 2D -> 2D or 2D ->3D reconstructions.

owaisahmad18 commented 1 year ago

Thanks a lot for responding. actually i also found out about MCRpy a week ago but i am still not sure how to reconstruct 2D structure from pymks data. for example

data_correlation = TwoPointCorrelation( periodic_boundary=True, cutoff=25, correlations=[(0,0),(0,1)] ).transform(data)

how can i use the output from TwoPointCorrelation command in pymks package and feed it to MCRpy to reconstruct microstructure. please help.

wd15 commented 1 year ago

Hi @owaisahmad18: I would assume that MCRpy uses Numpy arrays. data_correlation is likely a Dask array so you need to call numpy.array(data_correlation) on it to turn it into a Numpy array. Also check that it's shape is correct. You may also want to set cutoff=None if you want to to keep the correlation data the same shape as the image data for the purposes of reconstruction.

owaisahmad18 commented 1 year ago

To find twopointcorrelation i need to pass data_disc through Primitive Transformer which add another column and makes shape from (256x256) ---> (256x256x2) but reconstruct.py in MCRpy takes only (256X256)

image_asarray.shape = (256x256) data_disc = PrimitiveTransformer(nstate=2, min=0.0, max_=1.0).transform(image_asarray) data_disc.shape = (256x256x2) data_correlation = TwoPointCorrelation( periodic_boundary=True, cutoff=None, correlations=[(0,0),(0,1)] ).transform(data) data_correlation.shape = (256x255x2)

kindly suggest what should i do?

wd15 commented 1 year ago

To find twopointcorrelation i need to pass data_disc through Primitive Transformer which add another column and makes shape from (256x256) ---> (256x256x2) but reconstruct.py in MCRpy takes only (256X256)

image_asarray.shape = (256x256) data_disc = PrimitiveTransformer(nstate=2, min=0.0, max_=1.0).transform(image_asarray) data_disc.shape = (256x256x2) data_correlation = TwoPointCorrelation( periodic_boundary=True, cutoff=None, correlations=[(0,0),(0,1)] ).transform(data) data_correlation.shape = (256x255x2)

kindly suggest what should i do?

The final index will be the same length as the number of correlations requested with the correlations argument. Probably MCRpy will reconstruct the microstructure from a single correlation. Try using data_correlation[:, :, 0], for example, and see what happens.

owaisahmad18 commented 1 year ago

I tired it showed following error

Traceback (most recent call last): File "/home/owais/phase_evol/2pointstate/MCRpy-main/test_2/reconstruct.py", line 196, in main(args) File "/home/owais/phase_evol/2pointstate/MCRpy-main/test_2/reconstruct.py", line 57, in main convergence_data, last_frame = reconstruct( File "/home/owais/phase_evol/2pointstate/MCRpy-main/test_2/reconstruct.py", line 134, in reconstruct desired_descriptors = [descriptor_dict[d] for d in settings.descriptor_types] File "/home/owais/phase_evol/2pointstate/MCRpy-main/test_2/reconstruct.py", line 134, in desired_descriptors = [descriptor_dict[d] for d in settings.descriptor_types] File "/home/owais/miniconda3/lib/python3.9/site-packages/dask/array/core.py", line 1933, in getitem dt = self.dtype[index] KeyError: 'There are no fields in dtype float64.'

wd15 commented 1 year ago

I tired it showed following error

Traceback (most recent call last): File "/home/owais/phase_evol/2pointstate/MCRpy-main/test_2/reconstruct.py", line 196, in main(args) File "/home/owais/phase_evol/2pointstate/MCRpy-main/test_2/reconstruct.py", line 57, in main convergence_data, last_frame = reconstruct( File "/home/owais/phase_evol/2pointstate/MCRpy-main/test_2/reconstruct.py", line 134, in reconstruct desired_descriptors = [descriptor_dict[d] for d in settings.descriptor_types] File "/home/owais/phase_evol/2pointstate/MCRpy-main/test_2/reconstruct.py", line 134, in desired_descriptors = [descriptor_dict[d] for d in settings.descriptor_types] File "/home/owais/miniconda3/lib/python3.9/site-packages/dask/array/core.py", line 1933, in getitem dt = self.dtype[index] KeyError: 'There are no fields in dtype float64.'

Probably best to submit an issue to the MCRpy issue tracker, but it looks like it's expecting a Numpy array, not a Dask array.