Skip to content

Commit fd6c5c1

Browse files
Merge pull request #1577 from KrisThielemans/SPECTUB_clean
SPECTUB code clean-up (no change to functionality)
2 parents 5aa30eb + bb1d2b3 commit fd6c5c1

File tree

10 files changed

+284
-1729
lines changed

10 files changed

+284
-1729
lines changed

src/include/stir/recon_buildblock/PinholeSPECTUB_Tools.h

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
Copyright (C) 2014, 2021, University College London
55
This file is part of STIR.
66
7-
This software is distributed WITHOUT ANY WARRANTY;
8-
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7+
SPDX-License-Identifier: Apache-2.0
98
109
See STIR/LICENSE.txt for details
1110
@@ -16,7 +15,7 @@
1615
#ifndef _WM_SPECT_mph_H
1716
#define _WM_SPECT_mph_H
1817

19-
#include <iostream>
18+
#include <string>
2019
#include <vector>
2120

2221
namespace SPECTUB_mph
@@ -382,39 +381,21 @@ typedef struct
382381

383382
//... functions from wmtools_SPECT.cpp .........................................
384383

385-
void wm_alloc(int* Nitems, wm_da_type& wm, wmh_mph_type& wmh); // allocate wm
386-
387-
// void free_wm () ; // delete wm
388-
389-
// void write_wm_FC_mph (); // write double array weight matrix
390-
391-
// void write_wm_hdr_mph (); // write header of a matrix
392-
393-
// void write_wm_STIR_mph (); // write matrix in STIR format
384+
void wm_alloc(const int* Nitems, wm_da_type& wm, const wmh_mph_type& wmh); // allocate wm
394385

395386
void read_prj_params_mph(wmh_mph_type& wmh); // read ring parameters from a file
396387

397388
void read_coll_params_mph(wmh_mph_type& wmh); // read collimator parameters from a file
398389

399390
// void which_hole();
400391

401-
void fill_pcf(wmh_mph_type& wmh, pcf_type& pcf); // fill precalculated functions
402-
403-
// void free_pcf (); // fill precalculated functions
392+
void fill_pcf(const wmh_mph_type& wmh, pcf_type& pcf); // fill precalculated functions
404393

405394
void calc_cumsum(discrf2d_type* f);
406395

407-
void generate_msk_mph(bool* msk_3d, float* att, wmh_mph_type& wmh); // create a boolean mask for wm (no weights outside the msk)
408-
409-
// void read_msk_file_mph ( bool * msk ); // read mask from a file
410-
411-
std::string wm_SPECT_read_value_1d(std::ifstream* stream1, char DELIMITER);
412-
413-
void wm_SPECT_read_hvalues_mph(std::ifstream* stream1, char DELIMITER, int* nh, bool do_cyl, wmh_mph_type& wmh);
414-
415-
// void read_att_map_mph ( float *attmap ); // read attenuation map from a file
416-
417-
// char *itoa ( int n, char *s); // to convert integer to ascii
396+
void generate_msk_mph(bool* msk_3d,
397+
const float* att,
398+
const wmh_mph_type& wmh); // create a boolean mask for wm (no weights outside the msk)
418399

419400
void error_wmtools_SPECT_mph(int nerr, int ip, std::string txt); // error messages in wm_SPECT
420401

src/include/stir/recon_buildblock/PinholeSPECTUB_Weight3d.h

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
Copyright (C) 2014, 2021, University College London
55
This file is part of STIR.
66
7-
This software is distributed WITHOUT ANY WARRANTY;
8-
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7+
SPDX-License-Identifier: Apache-2.0
98
109
See STIR/LICENSE.txt for details
1110
@@ -24,49 +23,15 @@ void wm_calculation_mph(bool do_estim,
2423
psf2d_type* psf2d_bin,
2524
psf2d_type* psf_subs,
2625
psf2d_type* psf2d_aux,
27-
psf2d_type* kern,
28-
float* attmap,
29-
bool* msk_3d,
26+
const psf2d_type* kern,
27+
const float* attmap,
28+
const bool* msk_3d,
3029
int* Nitems,
31-
wmh_mph_type& wmh,
30+
const wmh_mph_type& wmh,
3231
wm_da_type& wm,
33-
pcf_type& pcf);
32+
const pcf_type& pcf);
3433

35-
//... geometric component ............................................
36-
37-
bool check_xang_par(voxel_type* vox, hole_type* h);
38-
39-
bool check_zang_par(voxel_type* vox, hole_type* h);
40-
41-
// bool check_xang_obl( lor_type * l, voxel_type * vox, hole_type * h);
42-
43-
// bool check_zang_obl( lor_type * l, voxel_type * vox, hole_type * h);
44-
45-
void voxel_projection_mph(lor_type* l, voxel_type* v, hole_type* h, wmh_mph_type& wmh);
46-
47-
void fill_psfi(psf2d_type* kern, wmh_mph_type& wmh);
48-
49-
void downsample_psf(psf2d_type* psf_in, psf2d_type* psf_out, int factor, bool do_calc);
50-
51-
void psf_convol(psf2d_type* psf1, psf2d_type* psf_aux, psf2d_type* psf2, bool do_calc);
52-
53-
float bresenh_f(int i1, int j1, int i2, int j2, float** f, int imax, int jmax, float dcr, wmh_mph_type& wmh, pcf_type& pcf);
54-
55-
void fill_psf_geo(psf2d_type* psf2d, lor_type* l, discrf2d_type* f, int factor, bool do_calc, wmh_mph_type& wmh);
56-
57-
void fill_psf_depth(psf2d_type* psf2d, lor_type* l, discrf2d_type* f, int factor, bool do_calc, wmh_mph_type& wmh, pcf_type& pcf);
58-
59-
void psf_convol(psf2d_type* psf2d, psf2d_type* psf_aux, psf2d_type* kern);
60-
61-
void downsample_psf(psf2d_type* psf_subs, psf2d_type* psf_bin);
62-
63-
//... attenuation...................................................
64-
65-
float calc_att_mph(bin_type bin, voxel_type vox, float* attmap, wmh_mph_type& wmh);
66-
67-
int comp_dist(float dx, float dy, float dz, float dlast);
68-
69-
void error_weight3d(int nerr, std::string txt); // error messages in weight3d_SPECT
34+
void fill_psfi(psf2d_type* kern, const wmh_mph_type& wmh);
7035

7136
} // namespace SPECTUB_mph
7237

src/include/stir/recon_buildblock/SPECTUB_Tools.h

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#ifndef _WM_SPECTUB_H
1414
#define _WM_SPECTUB_H
1515

16-
#include <iostream>
17-
#include <vector>
18-
1916
#include <string>
2017

2118
namespace SPECTUB
@@ -317,75 +314,29 @@ typedef struct
317314

318315
//... functions from wmtools_SPECT.cpp .........................................
319316

320-
void write_wm_FC(wm_da_type& wm); // to write double array weight matrix
321-
322-
void write_wm_hdr(wm_da_type& wm, wmh_type& wmh); // to write header of a matrix
323-
324-
void write_wm_STIR(SPECTUB::wm_da_type& wm); // to write matrix in STIR format
325-
326-
void index_calc(int* indexs, wmh_type& wmh); // to calculate projection index order in subsets
327-
328-
void read_Rrad(float* Rrad, wmh_type& wmh); // to read variable rotation radius from a text file (1 radius per line)
317+
void index_calc(int* indexs, const wmh_type& wmh); // to calculate projection index order in subsets
329318

330319
//
331320
// void col_params ( collim_type *COL ); // to fill collimator structure
332-
//
333-
// void read_col_params ( collim_type *COL); // to read collimator parameters from a file
334321

335-
void fill_ang(angle_type* ang, wmh_type& wmh, const float* Rrad); // to fill angle structure
322+
void fill_ang(angle_type* ang, const wmh_type& wmh, const float* Rrad); // to fill angle structure
336323

337324
void generate_msk(bool* msk_3d,
338325
bool* msk_2d,
339-
float* att,
340-
volume_type* vol,
341-
wmh_type& wmh); // to create a boolean mask for wm (no weights outside the msk)
342-
343-
void read_msk_file(bool* msk, wmh_type& wmh); // to read mask from a file
344-
345-
void read_att_map(float* attmap, wmh_type& wmh); // to read attenuation map from a file
326+
const float* att,
327+
const volume_type* vol,
328+
const wmh_type& wmh); // to create a boolean mask for wm (no weights outside the msk)
346329

347-
int max_psf_szb(angle_type* ang, wmh_type& wmh);
330+
int max_psf_szb(const angle_type* ang, const wmh_type& wmh);
348331

349332
float calc_sigma_h(voxel_type vox, collim_type COL);
350333

351-
float calc_sigma_v(voxel_type vox, collim_type COL, wmh_type& wmh);
352-
353-
char* itoa(int n, char* s); // to conver integer to ascii
334+
float calc_sigma_v(voxel_type vox, collim_type COL);
354335

355336
void free_wm(wm_type* f); // to free weight_mat
356337

357338
void free_wm_da(wm_da_type* f); // to free weight_mat_da
358339

359-
void error_wmtools_SPECT(int nerr, std::string txt); // error messages in wm_SPECT
360-
361-
//... functions from wm_SPECT.2.0............................
362-
363-
// int wm_SPECT( std::string inputFile);
364-
365-
// void error_wm_SPECT( int nerr, std::string txt); //list of error messages
366-
367-
////void wm_inputs( std::string fileName, proj_type * prj, volume_type *vol, voxel_type *vox, bin_type *bin );
368-
// void wm_inputs(char **argv,
369-
// int argc,
370-
// proj_type *prj,
371-
// volume_type *vol,
372-
// voxel_type *vox,
373-
// bin_type *bin);
374-
//
375-
//
376-
////void read_inputs( std::string param, proj_type * prj, volume_type *vol, voxel_type *vox, bin_type *bin );
377-
// void read_inputs(vector<std::string> param,
378-
// proj_type *prj,
379-
// volume_type *vol,
380-
// voxel_type *vox,
381-
//// bin_type *bin);
382-
//
383-
// extern wmh_type wmh; // weight matrix header. Global variable
384-
//
385-
// extern wm_da_type wm; // double array weight matrix structure. Global variable
386-
//
387-
// extern float * Rrad; // variable projection radius (in acquisition order)
388-
389340
} // namespace SPECTUB
390341

391342
#endif //_WM_SPECT_H

src/include/stir/recon_buildblock/SPECTUB_Weight3d.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void wm_calculation(const int kOS,
4141
const SPECTUB::discrf_type* const gaussdens,
4242
const int* const NITEMS,
4343
SPECTUB::wm_da_type& wm,
44-
SPECTUB::wmh_type& wmh,
44+
const SPECTUB::wmh_type& wmh,
4545
const float* Rrad);
4646

4747
void wm_size_estimation(int kOS,
@@ -55,7 +55,7 @@ void wm_size_estimation(int kOS,
5555
const int maxszb,
5656
const SPECTUB::discrf_type* const gaussdens,
5757
int* NITEMS,
58-
SPECTUB::wmh_type& wmh,
58+
const SPECTUB::wmh_type& wmh,
5959
const float* Rrad);
6060

6161
//... geometric component ............................................
@@ -64,21 +64,21 @@ void calc_gauss(SPECTUB::discrf_type* gaussdens);
6464

6565
void calc_vxprj(SPECTUB::angle_type* ang);
6666

67-
void voxel_projection(SPECTUB::voxel_type* vox, float* eff, float lngcmd2, SPECTUB::wmh_type& wmh);
67+
void voxel_projection(SPECTUB::voxel_type* vox, float* eff, float lngcmd2, const SPECTUB::wmh_type& wmh);
6868

6969
void fill_psf_no(SPECTUB::psf2da_type* psf,
7070
SPECTUB::psf1d_type* psf1d_h,
7171
const SPECTUB::voxel_type& vox,
7272
const angle_type* const ang,
7373
float szdx,
74-
SPECTUB::wmh_type& wmh);
74+
const SPECTUB::wmh_type& wmh);
7575

7676
void fill_psf_2d(SPECTUB::psf2da_type* psf,
7777
SPECTUB::psf1d_type* psf1d_h,
7878
const SPECTUB::voxel_type& vox,
7979
SPECTUB::discrf_type const* const gaussdens,
8080
float szdx,
81-
SPECTUB::wmh_type& wmh);
81+
const SPECTUB::wmh_type& wmh);
8282

8383
void fill_psf_3d(SPECTUB::psf2da_type* psf,
8484
SPECTUB::psf1d_type* psf1d_h,
@@ -88,10 +88,13 @@ void fill_psf_3d(SPECTUB::psf2da_type* psf,
8888
float szdx,
8989
float thdx,
9090
float thcmd2,
91-
wmh_type& wmh);
91+
const wmh_type& wmh);
9292

93-
void calc_psf_bin(
94-
float center_psf, float binszcm, SPECTUB::discrf_type const* const vxprj, SPECTUB::psf1d_type* psf, SPECTUB::wmh_type& wmh);
93+
void calc_psf_bin(float center_psf,
94+
float binszcm,
95+
SPECTUB::discrf_type const* const vxprj,
96+
SPECTUB::psf1d_type* psf,
97+
const SPECTUB::wmh_type& wmh);
9598

9699
//... attenuation...................................................
97100

@@ -103,7 +106,7 @@ void calc_psf_bin(
103106
void
104107
calc_att_path(const bin_type& bin, const SPECTUB::voxel_type& vox, const SPECTUB::volume_type& vol, SPECTUB::attpth_type* attpth);
105108

106-
float calc_att(const SPECTUB::attpth_type* const attpth, const float* const attmap, int islc, SPECTUB::wmh_type& wmh);
109+
float calc_att(const SPECTUB::attpth_type* const attpth, const float* const attmap, int islc, const SPECTUB::wmh_type& wmh);
107110

108111
int comp_dist(float dx, float dy, float dz, float dlast);
109112

0 commit comments

Comments
 (0)