Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ include_directories(strain PUBLIC
)

if(BUILD_TEST)
add_executable (tests ${CMAKE_CURRENT_SOURCE_DIR}/tests.cpp )
#TARGET_LINK_LIBRARIES (tests cilDVC Eigen3::Eigen)
target_link_libraries (tests cildvc_static)
include_directories(tests PUBLIC
${CMAKE_CURRENT_SOURCE_DIR} )
add_subdirectory(tests)
endif()

# BKB: commenting out next 2 lines for make of Core to work
Expand Down
20 changes: 20 additions & 0 deletions Core/tests/CMakeLists.txt
Comment thread
casperdcl marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
add_executable (tests ${CMAKE_CURRENT_SOURCE_DIR}/tests.cpp )
target_link_libraries (tests cildvc_static)
include_directories(tests PUBLIC ${CMAKE_SOURCE_DIR}/Core )

add_executable(test1 test_DataCloud.cpp)
target_link_libraries (test1 cildvc_static)
include_directories(test1 PUBLIC ${CMAKE_SOURCE_DIR}/Core )


install(TARGETS tests test1
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
)


message (WARNING "Adding test test1")

add_test(NAME DATACLOUD_test
COMMAND test1 datacloud_input.txt
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

53 changes: 53 additions & 0 deletions Core/tests/datacloud_input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
###############################################################################
#
#
# example dvc process control file
#
#
###############################################################################

# all lines beginning with a # character are ignored
# some parameters are conditionally required, depending on the setting of other parameters
# for example, if subvol_thresh is off, the threshold description parameters are not required

### file names
reference_filename reference.npy ### reference tomography image volume
correlate_filename correlate.npy ### correlation tomography image volume

point_cloud_filename grid_input.roi ### file of search point locations
output_filename 42kpoints_out ### base name for output files

### description of the image data files, all must be the same size and structure

vol_bit_depth 8 ### 8 or 16
vol_hdr_lngth 96 ### fixed-length header size, may be zero
vol_wide 20 ### width in pixels of each slice
vol_high 30 ### height in pixels of each slice
vol_tall 40 ### number of slices in the stack

### parameters defining the subvolumes that will be created at each search point

subvol_geom sphere ### cube, sphere
subvol_size 10 ### side length or diameter, in voxels
subvol_npts 8000 ### number of points to distribute within the subvol

subvol_thresh off ### on or off, evaluate subvolumes based on threshold
# gray_thresh_min 27 ### lower limit of a gray threshold range if subvol_thresh is on
# gray_thresh_max 127 ### upper limit of a gray threshold range if subvol_thresh is on
# min_vol_fract 0.2 ### only search if subvol fraction is greater than

### required parameters defining the basic the search process

disp_max 3 ### in voxels, used for range checking and global search limits
num_srch_dof 6 ### 3, 6, or 12
obj_function znssd ### sad, ssd, zssd, nssd, znssd
interp_type tricubic ### trilinear, tricubic

### optional parameters tuning and refining the search process

rigid_trans 3.0 4.0 0.0 ### rigid body offset of target volume, in voxels
basin_radius 0.0 ### coarse-search resolution, in voxels, 0.0 = none
subvol_aspect 1.0 1.0 1.0 ### subvolume aspect ratio

num_points_to_process 10

10 changes: 10 additions & 0 deletions Core/tests/grid_input.roi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1 543.814 391.457 630.000
2 527.698 419.369 630.000
3 511.583 447.282 630.000
4 571.821 407.627 630.000
5 555.706 435.540 630.000
6 539.590 463.452 630.000
7 615.944 395.884 630.000
8 599.829 423.797 630.000
9 583.713 451.710 630.000
10 567.598 479.622 630.000
167 changes: 167 additions & 0 deletions Core/tests/test_DataCloud.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#include "dvc.h"

/******************************************************************************/
void echo_vect_upto(std::vector<double> vect, unsigned int n)
{
std::cout << std::setprecision(6) << std::fixed;

for (unsigned int i = 0; i<vect.size(); i++)
if (i<n) std::cout << vect[i] << "\t";

}

/******************************************************************************/
int main(int argc, char *argv[])
{
int nProcessors = omp_get_num_procs();

int OMP_NUM_THREADS = omp_get_max_threads();

if (omp_get_max_threads() > nProcessors || !OMP_NUM_THREADS)
{
omp_set_num_threads(nProcessors);
}

#pragma omp parallel
{
if (omp_get_thread_num() == 0)
{
cout << "Running with threads = " << omp_get_num_threads() << endl;
}
}

InputRead in;

std::string help("help");
std::string example("example");
std::string manual("manual");

bool first_point = true;

// command entered with no arguments
if (argc == 1)
{
std::cout << endl;
std::cout << "Options:" << endl;
std::cout << "dvc dvc_in\t\t// execute dvc code with dvc_in controlling the run" << endl;
std::cout << "dvc help\t\t// provide additional detail about running the dvc code" << endl;
std::cout << "dvc example\t\t// print dvc_in_example with brief keyword descriptions" << endl;
std::cout << "dvc manual\t\t// print dvc_manual with more detailed information" << endl;
std::cout << endl;
return 1;
}

// trap help on the command line
if (argv[1] == help)
{
std::cout << endl;
std::cout << "Program execution is controlled by a key_word based input file." << endl;
std::cout << "Please refer to an example input file for content and format." << endl;
std::cout << "To run the code type dvc followed by the name of the input file." << endl;
std::cout << "The input file is evaluated and, if all is good, the run starts." << endl;
std::cout << "Common problems are incorrect file paths, missing keywords, and invalid parameters." << endl;
std::cout << "A message is sent to the console window if an input file problem is encountered." << endl;
std::cout << "Progrm execution can be lengthy, on the order of hours for large point clouds." << endl;
std::cout << "Results are written to output_filename.disp during execution." << endl;
std::cout << "Information about the run is written to output_filename.stat during execution." << endl;
std::cout << "Both files are simple text, and can be opened and viewed at any time." << endl;
std::cout << endl;
return 0;
}

// trap example on the command line
if (argv[1] == example)
{
std::cout << "\ndvc_in_example printed in the current working directory" << endl << endl;
std::ofstream dvc_inp("dvc_in_example");
in.print_input_example(dvc_inp, "fio_name");
in.print_input_example(dvc_inp, "vox_data");
in.print_input_example(dvc_inp, "sub_vols");
in.print_input_example(dvc_inp, "opt_mthd");
in.print_input_example(dvc_inp, "opt_tune");
dvc_inp.seekp(0, dvc_inp.beg);
dvc_inp.close();
return 0;
}

// trap manual on the command line
if (argv[1] == manual)
{
std::cout << "\ndvc_manual printed in the current working directory" << endl << endl;
std::ofstream dvc_man("dvc_manual");
in.print_manual_intro(dvc_man);
in.print_manual_section(dvc_man, "fio_name");
in.print_manual_section(dvc_man, "vox_data");
in.print_manual_section(dvc_man, "sub_vols");
in.print_manual_section(dvc_man, "opt_mthd");
in.print_manual_section(dvc_man, "opt_tune");
in.print_manual_output(dvc_man);
dvc_man.seekp(0, dvc_man.beg);
dvc_man.close();
return 0;
}

// check to see if the command line argument is an accessible file

std::string fname(argv[1]);
if (!in.input_file_accessible(fname)) return -1;

// instantiate storage for run control parameters within Utility

RunControl run;

// parse and check the input file

if (!in.input_file_read(&run)) return -2;

// instantiate a DataCloud
// organize_cloud can be lengthy, does (# points)*(# points) sorting

DataCloud data;

if (!in.read_point_cloud(&run, data.points, data.labels)) return -3;

data.organize_cloud(&run);

std::cout << "Checking results " << std::endl;

std::vector<std::vector<int>> solution = {};
std::vector<int> row = {
0, 1, 3, 4, 2, 7, 5, 6, 8, 9,
1, 0, 2, 4, 3, 5, 8, 9, 7, 6,
2, 1, 5, 4, 0, 9, 3, 8, 7, 6,
3, 4, 0, 7, 1, 8, 6, 5, 9, 2,
4, 5, 3, 8, 1, 9, 2, 0, 7, 6,
5, 4, 2, 9, 8, 1, 3, 0, 7, 6,
6, 7, 3, 8, 4, 0, 1, 9, 5, 2,
7, 6, 8, 3, 4, 9, 0, 5, 1, 2,
8, 9, 7, 4, 5, 3, 6, 1, 2, 0,
9, 8, 5, 4, 7, 2, 3, 1, 0, 6 };
for (int i = 0; i < 10; i++) {
std::vector<int> drow = {};
for (int j = 0; j < 10; j++) {
drow.push_back(row[i * 10 + j]);
}
}

std::ifstream infile("grid_input.roi.sorted");
int a, b, c, d, e, f, g, h, l, m;
int result = 0, j = 0;
while (infile >> a >> b >> c >> d >> e >> f >> g >> h >> l >> m)
{
std::vector<int> riga = { a,b,c,d,e,f,g,h,l,m};
for (int i = 0; i < 10; i++) {
//std::cout << "Checking results " << row[i + j* 10] << " " << riga[i] << std::endl;
if (row[i + j * 10] != riga[i]) {
result++;
}

}
j++;
}

std::cout << "Final result is " << result << std::endl;

return result;
}
/******************************************************************************/
Loading
Loading