Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - hilden

Pages: [1] 2
1
Automation / Re: Grayvalues for Material ID's using Python
« on: June 24, 2025, 02:42:11 PM »
Hi,

your code worked more or less for me. In your plot it seems, as if no solid material ID was found. Did you load the segmented structure file with material ID 1 and 2?

By the way, it would be great if you would copy paste your code here instead of using screenshots. Then, it would be easier for me to reproduce the problem ;) Use the "#" symbol above the editor to enter the code beginning and ending markers

However I did not understand, why you want to divide the X-values by 2? Then the histogram gets moved to the left. I assume, that you wanted to account for the problem of the different lengths of the arrays count and bin_edges. For that I think it would be better to just remove the last entry of bin_edges. Even better would be to use matplotlib instead to plot the histogram. You can find an example for a very basic plot below. Matplotlib offers many options to change the plotting style as desired.

Another improvement you find in my code example below is to get the gray values with numpy.where instead of a for loop. This is much faster for large gray value images.

Code: [Select]
import numpy as np
import matplotlib.pyplot as plt

VolumeInfo  = gd.getVolumeFieldsInfo() # get list of dictionaries of loaded Volume Fields and assign it to variable VolumeInfo
nx, ny, nz  = gd.getVolDimensions()    # get the number of voxels in X-, Y- and Z-direction and assign the numbers to variables
Structure   = gd.getStructure()        # assign 3D numpy array describing the loaded structure to the variable Structure

Name        = VolumeInfo[0]['name']    # assign the name of the volume field to the variable Name.
VolumeField = gd.getVolumeField(Name)  # assign the numpy array describing the volume field to the variable VolumeField
Statistic   = []                       # Create empty list to store the statistical values

grayvalues = np.empty((nx,ny,nz),dtype=np.float32) # create 3D numpy array with the same shape as the gray value image
material_ID = np.where(Structure[:,:,:]==1)        # find out where the structure has ID 1
grayvalues[material_ID]=VolumeField[material_ID]   # take the gray values where the structure has ID 1 and save them in the new field

flat      = grayvalues.flatten()

# ---------- plot with graph dialog GeoPy API ------------------
gDlg      = gd.makeGraphDialog()                   
graph     = gDlg.addGraph('Histogram', Name, "Voxel Count")
bin_count = 256
counts, bin_edges = np.histogram(flat,bins = bin_count, range=(0,255))

x_values = bin_edges[1:-1]   # crop the first value, because the number of zeros is not interesting, crop the last value to match the number of entries in counts
y_values = counts[1:]        # crop the first entry, because the number of zeros is not interesting
x_list   = x_values.tolist()
y_list   = y_values.tolist()

graph.addData(x_list,y_list, Name)     
gDlg.run()                                   

# ---------- plot with matplotlib ------------------
plt.hist(flat, bins=bin_edges)
plt.title('Histogram')
plt.xlabel('Gray Values')
plt.ylabel('Voxel Count')
plt.savefig('HistogramPlot.png')

2
Automation / Re: Job queue with student license
« on: June 23, 2025, 04:58:04 PM »
Hi TP,

following the topic in the User Guide I mentioned earlier, you can just record the execution of several macros into one. Just start Macro Recording and then in the Macro Execution Control select one macro after the other and click Record Only for each of them in the order you want to run them. Afterwards, end macro recording. Finally, you can run the new macro which then executes all the other macros automatically.

If you just want to run the same permeability simulation on different structures, it would be more elegant to just use one macro and the Python code shown in the tutorial I linked you in my earlier post. There, different structures are saved in one folder and the goal is to analyze Open and Closed Porosity on each of them automatically. You only have to replace the command for the open and closed porosity by the corresponding permeability simulation command.

Best regards,
Janine

3
Automation / Re: Job queue with student license
« on: June 23, 2025, 11:52:03 AM »
Hello,

yes, the job queue server is not included in your license. For a job queue server you would need a floating license to access GeoDict from different machines in your internal network. Then you and your colleagues could send jobs to a defined job queue server. With a node-locked license you only have access to GeoDict from one machine. Thus, you don't have a job server machine.

However, if you know the macros to run beforehand, you can create a macro, that runs the other macros one after the other. The macro execution can be recorded in a macro the same way as all other commands. Find an example in the User Guide:
https://geodict-userguide.math2market.de/2025/automation_varymacrofromgeopymacro.html

Also, if you want to run the same commands with varying parameters on different structures, you only need one macro. Learn how to create a parameter macro here:
https://geodict-userguide.math2market.de/2025/automation_createparametermacro.html

If you model the structures with the GeoDict structure generators, this can just be part of the macro. If you have a stack of structures, you can automatically run the study on all structure files in one folder as described in the tutorial "Automating the handling of multiple datasets with GeoPy". Download the tutorial from our website and request the password via e-mail.
https://www.math2market.com/service-support/learning-opportunities/tutorials.html

Does this help you?

Best regards,
Janine

4
Automation / Re: Grayvalues for Material ID's using Python
« on: June 13, 2025, 12:35:28 PM »
Hi,

I assume, your gray value image does not have index 1. If only one image is loaded it has always index 0. If more images are loaded, have a look at the Color By combo-box in the Volume Field tab. Counting starts with 0. The fields have the order in which they are loaded to GeoDict.
[attachimg=1]

Another thing I noted in your code example, is that the indentation does not seem to make sense within the loop. In the example in the User Guide it was meant like the following. I marked the significant differences to your code with "!!!".

Code: [Select]
VolumeInfo  = gd.getVolumeFieldsInfo() # get list of dictionaries of loaded Volume Fields and assign it to variable VolumeInfo
nx, ny, nz  = gd.getVolDimensions()    # get the number of voxels in X-, Y- and Z-direction and assign the numbers to variables
Structure   = gd.getStructure()        # assign 3D numpy array describing the loaded structure to the variable Structure

# !!! In the following command ensure to have the right index for your gray value field !!!
Name        = VolumeInfo[0]['name']    # assign the name of the volume field to the variable Name.
VolumeField = gd.getVolumeField(Name)  # assign the numpy array describing the volume field to the variable VolumeField
Statistic   = []                       # Create empty list to store the statistical values

for k in range(nz): # loop over all Z-layers
 value_sum   = 0    # creating variable value_sum to sum up the result values
 value_count = 0    # creating variable value_count to count the summands

 for j in range(ny):  # loop over all Y-layers

  for i in range(nx): # loop over all X-layers

    if Structure[i][j][k] == 0:                       # condition: if the kth Z-value in the jth Y-column of the ith X-layeris pore space (ID 0), the following indented section is executed
       value_sum   = value_sum + VolumeField[i][j][k] # add all pore space result values of the kth Z-layer to the sum value_sum
       value_count = value_count + 1                  # count the summands of value_sum

 # !!! The following section should have the right indentation according to what should be plotted. Since we want to have one value for each Z-layer it belongs to the outer loop (for k in range nz) and thus needs to have the same indentation level as the head of the second loop, here 1 space. !!!
 meanVal = value_sum / value_count # compute mean value of all pore space result values in the kth Z-layer and assign it to the variable meanVal
 Statistic.append(meanVal)         # append the mean value of the Z-layer to the Statistic list

# !!! The following section needs to be outside of the loop to plot all data in one plot !!!
gDlg  = gd.makeGraphDialog()                  # create a graph dialog object
graph = gDlg.addGraph(Name, "Z layers", Name) # add a graph object with the name of the volume field as title and Y-axis legend and Z-layers as X-axis legend 
Z_layers = list(range(1, nz + 1))             # writes the Z-layer numbers 1, 2, …, nz-1, nz into a list named Z-layers
graph.addData(Z_layers, Statistic, Name)      # add a single dataset with the Z-layers as X-values, the mean result values as Y-values and the name of the volume field as legend to this graph
gDlg.run()                                    # show graph dialog

This will output something like this:
[attachimg=2]



5
Hello Caroline,

you can reduce the number of data points in the Electrolyte Model Parameters. Then, less computations are done for the meso parameters.

We have a tutorial for creating the txt files. This tutorial also has txt files for many of the database materials including NMC622. You can download it here: https://www.gddownload.de/Tutorials/Create-txt-file-for-concentration-dependent-parameters-in-active-material-expert-settings.zip
The password can be requested here: https://www.math2market.com/service-support/technical-support.html
But I will just send you the password via e-mail.

Best regards,
Janine

6
Hello Caroline,

do you run a homogenized simulation? For the homogenized simulation currently the meso parameters are computed for each data point from the concentration dependent parameter tables, which takes much time. With the upcoming Service Pack 3 for GeoDict 2025 it is possible to reduce this time. For this, set the Separator and  Binder & Carbon Black model parameters to porous and the input mode of the effective values to Tortuosity Factors. Then, the meso parameter can be computed from the tortuosity, which is much faster.

For the active material you can use concentration dependent parameters by using an expert setting as described in this YouTube tutorial: https://www.youtube.com/watch?v=wEhk8YZtQSI

Best regards,
Janine

7
Hello Jack,

there are many options to analyze volume fields with the Compute Metrics command, as described here: https://geodict-userguide.math2market.de/2025/geodict_computemetrics.html

For example, you can compute the mean value and standard deviation for a specific material with it. However, the option to compute the histogram for only one material is not included yet.

But if needed, you can use Python to create your own custom histogram GeoApp.

For example, you get a 3D numpy array of your structure using the command gd.getStructure() as described here:
https://geodict-userguide.math2market.de/2025/automation_api_structure.html?anchor=getstructure

and for your volume field using gd.getVolumefield(volume field index), as described here:
https://geodict-userguide.math2market.de/2025/automation_api-results.html?anchor=getvolumefield

Then, you can for example use numpy methods to get a histogram for only one material ID.
https://numpy.org/doc/stable/index.html

Best regards,
Janine

8
Hi Mark,

reassigning only a part of a material should be possible with GeoPy, but not directly from the GUI. But did you try to crop each material and embed it again, after having them split by the app or an own GeoPy script? Then adding them together with LayerGeo Add, as suggested before? You could even use a table variable to set the cropping values as needed. I think, this is the easiest way for the task at the moment. So maybe step after step:

1. split the structure in it's materials, e.g. for a structure with 2 solid materials, split the structure in two structures, one only containing material 1 and one only containing material 2. This can be done by reassigning the other materials to the pore material and saving the structure afterwards.
2. If for example only material 1 should be clipped, crop the structure only containing material 1 and embed it afterwards with pore material to obtain the same domain size as before.
3. Use the module LayerGeo Add to add the differently cropped materials together.
[attachimg=1]

You can script all these steps in a GeoPy script and set a variable of type table, as explained in the GeoPy scripting User Guide on page 46. Then, you can define the cropping values for each material.

Best regards,
Janine

9
Hi Mark,

right away from the GUI it is currently not possible. But there could be other possibilities.

The Easy Image GeoApp can do a similar thing. There is an option called Split Structure by Materials. This splits the materials into different structures and adds them together again but shifted. This app can be found under GeoApp -> General -> Report & Image ->Easy Image. The parameter options open after clicking Run. For Image Presets select Split Structure by Material. There is also a YouTube tutorial for this feature https://www.youtube.com/watch?v=dVCApDddQPo. The tutorial is done with GeoDict 2020. Thus, the app is located in another place, but the functionality did not change much.

You could use the resulting structure parts and crop them as needed and add them again afterwards with LayerGeo - Add. If you need this often, you can write a GeoPy script for this task.

Best regards,
Janine

10
Automation / Re: Extract saturated structures with Python
« on: May 23, 2024, 04:03:11 PM »
Hi,

yes, there is. The values can be found in the Resultmap. Thus, you can access them from Python via the stringmap package. Find a detailed description for the stringmap options in the GeoPy Scripting User Guide on page 81 (https://www.math2market.com/fileadmin/UserGuide/GeoDict2024/Automation2024.pdf). Below find an example how the file with the saturation closest to 0.5 can be found.

Code: [Select]
import stringmap

gdr = stringmap.parseGDR("CapillaryPressureResult.gdr")
gdr.push("ResultMap")
saturationlist = gdr.getList("SaturationInvading")
print(saturationlist)

def getSaturationIndex(saturationvalue):
  saturationdifference = 1
  for saturation in saturationlist:
    diff = abs(saturationvalue-float(saturation))
    print(diff)
    if diff < saturationdifference:
      saturationdifference=diff
    else:
      saturationindex = saturationlist.index(saturation)
      break
  return saturationindex
 
file = f"CapillaryPressureResult/Step_{getSaturationIndex(0.5):06}.gdt"

11
Automation / Re: Add Description to Resultfile with python macro
« on: May 15, 2024, 12:46:12 PM »
Hello Mark,

you can change the result file from Python after the generation using the stringmap package. This package is described in the GeoPy scripting User Guide in the chapter "Access to GeoDict result files (*.gdr)" on page 81.
 https://www.math2market.com/fileadmin/UserGuide/GeoDict2024/Automation2024.pdf

I give you a short example code to change the description in the metadata tab of a FlowDict result viewer:

Code: [Select]
import stringmap
gdr=stringmap.parseGDR('StokesResult.gdr')
GDR_Description=gdr['Description']
gdr['Description']='some text\n'+GDR_Description
gdr.toFile('new.gdr')

Find the needed keys for the result part to change by printing the gdr in the console
Code: [Select]
print(gdr)
Best regards,
Janine

12
CT, µCT and FIB-SEM / Re: Labeling for AI segmentation
« on: November 29, 2023, 03:29:05 PM »
Hi Erik,

  • It is possible by using a GeoPy script. Attached find a script that labels the given gray value ranges with the according IDs. To run the script, the gray value image should be loaded in the Image Processing dialog. From the main GeoDict window select Macro - Execute Macro/Script and browse for the script. Click on Parameters to assign material IDs to value ranges in a table. Afterwards click Run to generate an AI-label file (*.gld). Load this file in the Image Processing dialog by clicking Load Labels and browsing for the file. To learn more about automation by scripting in GeoDict, refer to the GeoPy scripting User Guide: https://www.geodict.com/fileadmin/UserGuide/GeoDict2023/Automation2023.pdf.
  • Good news for you: With the new GeoDict 2024 release coming soon, a new feature is available. The "Magic Brush" analyzes the scan on clusters recognizing edges. Then, labels can be created by simply selecting these clusters.


Best regards,
Janine

13
Hello Erik,

Yes, there is. In the 3D Image Processing dialog under the Image Processing tab unfold Image Alignment and then Rotation. Select Automatic Rotation and choose Plane from the Automation Mode pull-down menu. When clicking apply the image is automatically aligned with two major axes. If you want to see a preview of the automatic rotation first, you can just click Suggest - Plane and observe the rotation overlay in the 2D visualization of your scan on the right.

Best regards,
Janine

14
Image Analysis / Re: Number of overlap points and angles
« on: August 31, 2023, 09:42:19 AM »
Hi Elise,

the number of overlap points you can obtain with MatDict -> GAD Objects Analysis -> Analyze Objects. The Results-Report tab in the Result Viewer shows the Number of Overlap Objects.

To analyze only one overlap object, you could for example right-click in the structure in an overlap region. The context menu offers the possibility to Select GAD objects. Use the first option to select all GAD-objects in this point. Then on the right open the GAD Object Selection tab from the side bar. Click Edit Objects and obtain the direction (orientation) from all of the fibers.

Finding all angles could be automated in a Python script. How exactly should the result look like? Something like a table with the overlap indices in one column and the angles for each of these overlap objects in the right column? If there are more than two fibers crossing, should each angle between every combination of the fibers be given? Or do you need only the orientations of all the fibers in the different points?

Best regards,
Janine

15
Image Analysis / Re: GeoDict-AI
« on: January 23, 2023, 12:28:14 PM »
Dear Ziho,

Yes, this is possible. You only need to create the same folder structure as Create Training Data would generate.

  • Create an empty folder with a meaningful name.
  • Inside create the folder Train. If needed also a folder Test can be created for the Validate Performance feature.
  • Inside the Train folder create as many folders as you have training data, named as desired for example in counting numbers starting with 0 as is done by the Create Training Data feature.
  • Inside each of these subfolders place an input.gdt and an output.gdt file. The input.gdt must have only two IDs (ID00 Pore and ID01 Solid) and output.gdt three ( ID00 Pore, ID01 Grains and ID02 Binder)
I hope, my answer helped you.
Best regards, Janine

Pages: [1] 2