Skip to content

Commit db84d46

Browse files
committed
Use estimated COR and choice of recons method
1 parent 4f923ac commit db84d46

6 files changed

Lines changed: 75 additions & 19 deletions

File tree

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,18 @@
2323
dif: 1000 # A difference between the outlier value and the median value of neighbouring pixels.
2424
save_result: true
2525
# --- Center of Rotation auto-finding. Required for reconstruction bellow. ---
26-
- method: find_center_vo
27-
module_path: httomolibgpu.recon.rotation
26+
- method: find_center
27+
module_path: tomopy.recon.rotation
2828
parameters:
29-
ind: null # A vertical slice (sinogram) index to calculate CoR, `mid` can be used for middle
30-
average_radius: 0 # Average several sinograms to improve SNR, one can try 3-5 range
31-
cor_initialisation_value: null # Use if an approximate CoR is known
32-
smin: -50
33-
smax: 50
34-
srad: 6.0
35-
step: 0.5
36-
ratio: 0.5
37-
drop: 20
29+
ind: null
30+
init: <INITCOR>
31+
tol: 0.5
32+
mask: true
33+
ratio: 1.0
34+
sinogram_order: false
3835
id: centering
3936
side_outputs:
40-
cor: centre_of_rotation # A side output of the method, here a CoR scalar value
37+
cor: centre_of_rotation
4138
# --- Reconstruction method. ---
4239
- method: FBP2d_astra
4340
module_path: httomolibgpu.recon.algorithm
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
module_path: tomopy.recon.rotation
2727
parameters:
2828
ind: null
29-
init: 48
29+
init: <INITCOR>
3030
tol: 0.5
3131
mask: true
3232
ratio: 1.0

i14/notebooks/xrf_tomo_align_initial.ipynb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"inpath = \"\"\n",
2626
"outpath_nexus = None\n",
2727
"outpath_shifts = None\n",
28+
"outpath_cor = None\n",
2829
"alignment_section = \"all\"\n",
2930
"alignment_band = 15\n",
3031
"cropping = \"auto\"\n",
@@ -895,6 +896,24 @@
895896
"np.savetxt(outpath_shifts, shifts+delta_shifts, delimiter=\" \")\n",
896897
"np.savetxt(outpath_limits, [cmin, cmax], delimiter=\" \")"
897898
]
899+
},
900+
{
901+
"cell_type": "markdown",
902+
"id": "16c977de-ca7b-4afb-a564-780df133334b",
903+
"metadata": {},
904+
"source": [
905+
"## Saving estimated centre of rotation to a TXT file"
906+
]
907+
},
908+
{
909+
"cell_type": "code",
910+
"execution_count": null,
911+
"id": "a1784c75-6b2a-4e48-84d3-315d70311562",
912+
"metadata": {},
913+
"outputs": [],
914+
"source": [
915+
"np.savetxt(outpath_cor, np.array([(cmax-cmin)/2]))"
916+
]
898917
}
899918
],
900919
"metadata": {

i14/schema/xrfTomoSchema.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"alignmentSection": {
4242
"type": "string",
43-
"enum": ["all", "top", "middle", "bottom"],
43+
"enum": ["all", "top", "middle", "bottom"],
4444
"title": "Section for alignment",
4545
"description": "The section of the projections to be used for the initial alignment."
4646
},
@@ -59,6 +59,12 @@
5959
"type": "number",
6060
"title": "Centre of rotation",
6161
"description": "Optional value for centre of rotation for the tomographic reconstruction, using Vo centering method if not provided."
62+
},
63+
"reconsMethod" : {
64+
"type": "string",
65+
"enum": ["FBP", "OLEM"],
66+
"title": "Reconstruction Method",
67+
"description": "The method to be used for reconstruction. FBP is default. OLEM might provide smoother results."
6268
}
6369
},
6470
"required": ["outputFolder", "multiScan", "multiEdge"],

i14/schema/xrfTomoUISchema.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,18 @@
7171
]
7272
},
7373
{
74-
"type": "Control",
75-
"scope": "#/properties/cor"
76-
},
74+
"type": "HorizontalLayout",
75+
"elements": [
76+
{
77+
"type": "Control",
78+
"scope": "#/properties/cor"
79+
},
80+
{
81+
"type": "Control",
82+
"scope": "#/properties/reconsMethod"
83+
}
84+
]
85+
},
7786
{
7887
"type": "Control",
7988
"scope": "#/properties/outputFolder"

i14/templates/xrf-tomo-template.yaml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ spec:
4040
value: true
4141
- name: cor
4242
value: "null"
43+
- name: reconsMethod
44+
value: "FBP"
4345
volumeClaimTemplates:
4446
- metadata:
4547
name: tmp
@@ -60,11 +62,21 @@ spec:
6062
command: [bash]
6163
source: |
6264
OUTPUT="{{`{{ workflow.parameters.visitdir }}`}}"/processing/workflows/"{{`{{ workflow.parameters.outputFolder }}`}}"
65+
METHOD="{{`{{ workflow.parameters.reconsMethod }}`}}"
6366
mkdir -p $OUTPUT
6467
echo '{{ .Files.Get "notebooks/xrf_tomo_align_initial.ipynb" | b64enc }}' | base64 -d > $OUTPUT/align_initial.ipynb
6568
echo '{{ .Files.Get "notebooks/xrf_tomo_align_and_normalise.ipynb" | b64enc }}' | base64 -d > $OUTPUT/align_and_normalise.ipynb
6669
echo '{{ .Files.Get "notebooks/xrf_tomo_plotting.ipynb" | b64enc }}' | base64 -d > $OUTPUT/plotting.ipynb
67-
echo '{{ .Files.Get "configs/httomo_config_olem.yaml" | b64enc }}' | base64 -d > $OUTPUT/httomo.yaml
70+
echo '{{ .Files.Get "configs/httomo_config_OLEM.yaml" | b64enc }}' | base64 -d > $OUTPUT/httomo_OLEM.yaml
71+
echo '{{ .Files.Get "configs/httomo_config_FBP.yaml" | b64enc }}' | base64 -d > $OUTPUT/httomo_FBP.yaml
72+
if [ "$METHOD" = "OLEM" ]; then
73+
mv $OUTPUT/httomo_OLEM.yaml $OUTPUT/httomo.yaml
74+
rm $OUTPUT/httomo_FBP.yaml
75+
fi
76+
if [ "$METHOD" = "FBP" ]; then
77+
mv $OUTPUT/httomo_FBP.yaml $OUTPUT/httomo.yaml
78+
rm $OUTPUT/httomo_OLEM.yaml
79+
fi
6880
volumes:
6981
- name: session
7082
hostPath:
@@ -136,6 +148,7 @@ spec:
136148
-p inpath "tomo_xrf_${START}_${END}_${EDGE}.nxs" \
137149
-p outpath_nexus "${EDGE}_aligned_initial.nxs" \
138150
-p outpath_shifts "${EDGE}_shifts.txt" \
151+
-p outpath_cor "${EDGE}_cor.txt" \
139152
-p alignment_section "{{`{{ workflow.parameters.alignmentSection }}`}}" \
140153
-p alignment_band "{{`{{ workflow.parameters.alignmentBand }}`}}"
141154
--prepare-only
@@ -147,6 +160,10 @@ spec:
147160
- name: tmp
148161
mountPath: /tmp
149162
outputs:
163+
parameters:
164+
- name: initcor
165+
valueFrom:
166+
path: "{{`{{ workflow.parameters.visitdir }}`}}/processing/workflows/{{`{{ workflow.parameters.outputFolder }}`}}/{{`{{ workflow.parameters.elementToAlign }}`}}-{{`{{ workflow.parameters.transitionToAlign }}`}}_cor.txt"
150167
artifacts:
151168
- name: align_initial
152169
path: "{{`{{ workflow.parameters.visitdir }}`}}/processing/workflows/{{`{{ workflow.parameters.outputFolder }}`}}/_assets/align_initial.html"
@@ -263,6 +280,7 @@ spec:
263280
inputs:
264281
parameters:
265282
- name: edge
283+
- name: initcor
266284
script:
267285
image: ghcr.io/diamondlightsource/httomo:3.2.1
268286
env:
@@ -282,8 +300,10 @@ spec:
282300
TRANSITION="{{`{{= sprig.mustFromJson(inputs.parameters.edge).edgeTransition }}`}}"
283301
mkdir -p $OUTPUT/httomo_output
284302
303+
COR_ESTIMATE="{{`{{ inputs.parameters.initcor }}`}}"
304+
[[ $COR_ESTIMATE != "null" ]] && sed -i 's/<INITCOR>/'"${COR_ESTIMATE}"'/' $OUTPUT/httomo.yaml
285305
COR="{{`{{ workflow.parameters.cor }}`}}"
286-
[[ $COR != "null" ]] && sed -i 's/${{`{{centering.side_outputs.centre_of_rotation}}`}}/'"${COR}"'/' $OUTPUT/httomo.yaml
306+
[[ $COR != "null" ]] && sed -i 's/${{`{{centering.side_outputs.centre_of_rotation}}`}}/'"${COR}"'/' $OUTPUT/httomo.yaml
287307
288308
cmd=(/opt/conda/bin/mpirun -n 1 /opt/conda/bin/python -m httomo run)
289309
cmd+=("--output-folder-name=${ELEMENT}-${TRANSITION}")
@@ -416,6 +436,7 @@ spec:
416436
inputs:
417437
parameters:
418438
- name: edge
439+
- name: initcor
419440
dag:
420441
tasks:
421442
- name: alignment
@@ -430,6 +451,8 @@ spec:
430451
parameters:
431452
- name: edge
432453
value: "{{`{{ inputs.parameters.edge }}`}}"
454+
- name: initcor
455+
value: "{{`{{ inputs.parameters.initcor }}`}}"
433456
dependencies: [alignment]
434457

435458
- name: xrf-tomo-pipeline
@@ -461,6 +484,8 @@ spec:
461484
parameters:
462485
- name: edge
463486
value: "{{`{{ item }}`}}"
487+
- name: initcor
488+
value: "{{`{{ tasks.generate-shifts.outputs.parameters.initcor }}`}}"
464489
withParam: "{{`{{ workflow.parameters.multiEdge }}`}}"
465490

466491
- name: show-results

0 commit comments

Comments
 (0)