Skip to content

Commit

Permalink
change tipl namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
frankyeh committed Apr 26, 2018
1 parent 1e6300e commit d43f4cb
Show file tree
Hide file tree
Showing 89 changed files with 1,686 additions and 1,686 deletions.
60 changes: 30 additions & 30 deletions SliceModel.h
@@ -1,7 +1,7 @@
#ifndef SliceModelH
#define SliceModelH
#include <future>
#include "image/image.hpp"
#include "tipl/tipl.hpp"
#include "libs/gzip_interface.hpp"

// ---------------------------------------------------------------------------
Expand All @@ -11,12 +11,12 @@ class SliceModel {
std::shared_ptr<fib_data> handle;
int view_id;
bool is_diffusion_space = true;
image::matrix<4,4,float> T,invT; // T: image->diffusion iT: diffusion->image
image::geometry<3>geometry;
image::vector<3,float>voxel_size;
tipl::matrix<4,4,float> T,invT; // T: image->diffusion iT: diffusion->image
tipl::geometry<3>geometry;
tipl::vector<3,float>voxel_size;
public:
// for directx
image::vector<3,int> slice_pos;
tipl::vector<3,int> slice_pos;
bool slice_visible[3];
public:
SliceModel(std::shared_ptr<fib_data> new_handle,int view_id_);
Expand All @@ -28,11 +28,11 @@ class SliceModel {
std::pair<unsigned int,unsigned int> get_contrast_color(void) const;
void set_contrast_range(float min_v,float max_v);
void set_contrast_color(unsigned int min_c,unsigned int max_c);
void get_slice(image::color_image& image,
unsigned char,const image::value_to_color<float>& v2c,
void get_slice(tipl::color_image& image,
unsigned char,const tipl::value_to_color<float>& v2c,
const SliceModel* overlay,
const image::value_to_color<float>& overlay_v2c) const;
image::const_pointer_image<float, 3> get_source(void) const;
const tipl::value_to_color<float>& overlay_v2c) const;
tipl::const_pointer_image<float, 3> get_source(void) const;

public:
template<typename value_type1,typename value_type2>
Expand All @@ -41,22 +41,22 @@ class SliceModel {
{
if(!is_diffusion_space)
{
image::vector<3,float> v;
image::slice2space(cur_dim, x, y, slice_pos[cur_dim], v[0],v[1],v[2]);
tipl::vector<3,float> v;
tipl::slice2space(cur_dim, x, y, slice_pos[cur_dim], v[0],v[1],v[2]);
v.to(T);
v.round();
px = v[0];
py = v[1];
pz = v[2];
}
else
image::slice2space(cur_dim, x, y, slice_pos[cur_dim], px, py, pz);
tipl::slice2space(cur_dim, x, y, slice_pos[cur_dim], px, py, pz);
}
void toOtherSlice(const SliceModel* other_slice,
unsigned char cur_dim,float x,float y,
image::vector<3,float>& v) const
tipl::vector<3,float>& v) const
{
image::slice2space(cur_dim, x, y, slice_pos[cur_dim], v[0],v[1],v[2]);
tipl::slice2space(cur_dim, x, y, slice_pos[cur_dim], v[0],v[1],v[2]);
if(!is_diffusion_space)
v.to(T);
if(!other_slice->is_diffusion_space)
Expand All @@ -66,16 +66,16 @@ class SliceModel {
bool to3DSpace(unsigned char cur_dim,value_type x, value_type y,
value_type& px, value_type& py, value_type& pz) const
{
image::slice2space(cur_dim, x, y, slice_pos[cur_dim], px, py, pz);
tipl::slice2space(cur_dim, x, y, slice_pos[cur_dim], px, py, pz);
return geometry.is_valid(px, py, pz);
}


public:
void get_texture(unsigned char dim,image::color_image& cur_rendering_image,
const image::value_to_color<float>& v2c,
void get_texture(unsigned char dim,tipl::color_image& cur_rendering_image,
const tipl::value_to_color<float>& v2c,
const SliceModel* overlay,
const image::value_to_color<float>& overlay_v2c)
const tipl::value_to_color<float>& overlay_v2c)
{
get_slice(cur_rendering_image,dim,v2c,overlay,overlay_v2c);
for(unsigned int index = 0;index < cur_rendering_image.size();++index)
Expand Down Expand Up @@ -116,24 +116,24 @@ class SliceModel {
}
return has_updated;
}
void get_slice_positions(unsigned int dim,std::vector<image::vector<3,float> >& points)
void get_slice_positions(unsigned int dim,std::vector<tipl::vector<3,float> >& points)
{
points.resize(4);
image::get_slice_positions(dim, slice_pos[dim], geometry,points);
tipl::get_slice_positions(dim, slice_pos[dim], geometry,points);
if(!is_diffusion_space)
for(unsigned int index = 0;index < points.size();++index)
points[index].to(T);
}
void get_mosaic(image::color_image& image,
void get_mosaic(tipl::color_image& image,
unsigned int mosaic_size,
const image::value_to_color<float>& v2c,
const tipl::value_to_color<float>& v2c,
unsigned int skip,
const SliceModel* overlay,
const image::value_to_color<float>& overlay_v2c);
void apply_overlay(image::color_image& show_image,
const tipl::value_to_color<float>& overlay_v2c);
void apply_overlay(tipl::color_image& show_image,
unsigned char dim,
const SliceModel* other_slice,
const image::value_to_color<float>& overlay_v2c) const;
const tipl::value_to_color<float>& overlay_v2c) const;
};

class CustomSliceModel : public SliceModel {
Expand All @@ -142,9 +142,9 @@ class CustomSliceModel : public SliceModel {
public:
std::auto_ptr<std::future<void> > thread;

image::const_pointer_image<float,3> from;
image::vector<3> from_vs;
image::affine_transform<double> arg_min;
tipl::const_pointer_image<float,3> from;
tipl::vector<3> from_vs;
tipl::affine_transform<double> arg_min;
bool terminated;
bool ended;
CustomSliceModel(std::shared_ptr<fib_data> new_handle);
Expand All @@ -154,11 +154,11 @@ class CustomSliceModel : public SliceModel {
}

void terminate(void);
void argmin(image::reg::reg_type reg_type);
void argmin(tipl::reg::reg_type reg_type);
void update(void);

public:
image::basic_image<float, 3> source_images;
tipl::image<float, 3> source_images;
public:

bool initialize(const std::vector<std::string>& files,bool correct_intensity);
Expand Down
12 changes: 6 additions & 6 deletions cmd/ana.cpp
Expand Up @@ -4,7 +4,7 @@
#include <iostream>
#include <iterator>
#include <string>
#include "image/image.hpp"
#include "tipl/tipl.hpp"
#include "tracking/region/Regions.h"
#include "libs/tracking/tract_model.hpp"
#include "libs/tracking/tracking_thread.hpp"
Expand Down Expand Up @@ -126,19 +126,19 @@ void export_track_info(const std::string& file_name,
{
file_name_stat += ".bmp";
std::cout << "export subvoxel TDI to " << file_name_stat << std::endl;
image::basic_image<image::rgb_color,3> tdi;
image::matrix<4,4,float> tr;
tipl::image<tipl::rgb,3> tdi;
tipl::matrix<4,4,float> tr;
tr.identity();
if(cmd == "tdi_color")
tdi.resize(handle->dim);
else
{
tdi.resize(image::geometry<3>(handle->dim[0]*4,handle->dim[1]*4,handle->dim[2]*4));
tdi.resize(tipl::geometry<3>(handle->dim[0]*4,handle->dim[1]*4,handle->dim[2]*4));
tr[0] = tr[5] = tr[10] = 4.0f;
}
tract_model.get_density_map(tdi,tr,false);
image::basic_image<image::rgb_color,2> mosaic;
image::mosaic(tdi,mosaic,std::sqrt(tdi.depth()));
tipl::image<tipl::rgb,2> mosaic;
tipl::mosaic(tdi,mosaic,std::sqrt(tdi.depth()));
QImage qimage((unsigned char*)&*mosaic.begin(),
mosaic.width(),mosaic.height(),QImage::Format_RGB32);
qimage.save(file_name_stat.c_str());
Expand Down
14 changes: 7 additions & 7 deletions cmd/atl.cpp
Expand Up @@ -2,7 +2,7 @@
#include <QFileInfo>
#include <QApplication>
#include <QDir>
#include "image/image.hpp"
#include "tipl/tipl.hpp"
#include "mapping/fa_template.hpp"
#include "libs/gzip_interface.hpp"
#include "mapping/atlas.hpp"
Expand Down Expand Up @@ -64,10 +64,10 @@ bool atl_load_atlas(std::string atlas_name)
return true;
}

void atl_save_mapping(const std::string& file_name,const image::geometry<3>& geo,
const image::basic_image<image::vector<3>,3>& mapping,
void atl_save_mapping(const std::string& file_name,const tipl::geometry<3>& geo,
const tipl::image<tipl::vector<3>,3>& mapping,
const std::vector<float>& trans,
const image::vector<3>& vs,
const tipl::vector<3>& vs,
bool multiple)
{
for(unsigned int i = 0;i < atlas_list.size();++i)
Expand All @@ -82,17 +82,17 @@ void atl_save_mapping(const std::string& file_name,const image::geometry<3>& geo
output += atlas_list[i].get_list()[j];
output += ".nii.gz";

image::basic_image<unsigned char,3> roi(geo);
tipl::image<unsigned char,3> roi(geo);
for(unsigned int k = 0;k < mapping.size();++k)
if (atlas_list[i].is_labeled_as(mapping[k], j))
roi[k] = 1;
if(multiple)
{
image::io::nifti out;
tipl::io::nifti out;
out.set_voxel_size(vs);
if(!trans.empty())
out.set_LPS_transformation(trans.begin(),roi.geometry());
image::flip_xy(roi);
tipl::flip_xy(roi);
out << roi;
out.save_to_file(output.c_str());
std::cout << "save " << output << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions cmd/cnn.cpp
@@ -1,13 +1,13 @@
#include <QApplication>
#include <QFileInfo>
#include "program_option.hpp"
#include "image/image.hpp"
#include "tipl/tipl.hpp"
#include "gzip_interface.hpp"

int cnn(void)
{
std::string train_file_name = po.get("train");
image::ml::network_data<float,unsigned char> nn_data,nn_test;
tipl::ml::network_data<float,unsigned char> nn_data,nn_test;
if(!nn_data.load_from_file<gz_istream>(train_file_name.c_str()))
{
std::cout << "Cannot load training data at " << train_file_name << std::endl;
Expand All @@ -23,7 +23,7 @@ int cnn(void)
}
}
std::string network = po.get("network");
image::ml::network nn;
tipl::ml::network nn;

if(!(nn << network))
{
Expand Down
16 changes: 8 additions & 8 deletions cmd/exp.cpp
Expand Up @@ -2,7 +2,7 @@
#include <iostream>
#include <iterator>
#include <string>
#include "image/image.hpp"
#include "tipl/tipl.hpp"
#include "tracking/region/Regions.h"
#include "libs/tracking/tract_model.hpp"
#include "libs/dsi/image_model.hpp"
Expand Down Expand Up @@ -66,7 +66,7 @@ int exp(void)
if(mat_reader.read("trans",row,col,trans))
std::cout << "Transformation matrix found." << std::endl;

image::geometry<3> geo(dim_buf[0],dim_buf[1],dim_buf[2]);
tipl::geometry<3> geo(dim_buf[0],dim_buf[1],dim_buf[2]);
std::string export_option = po.get("export");
std::replace(export_option.begin(),export_option.end(),',',' ');
std::istringstream in(export_option);
Expand All @@ -88,10 +88,10 @@ int exp(void)
continue;
}

image::basic_image<float,4> fibers;
tipl::image<float,4> fibers;
if(cmd[3] == 's') // all directions
{
fibers.resize(image::geometry<4>(geo[0],geo[1],geo[2],dir.num_fiber*3));
fibers.resize(tipl::geometry<4>(geo[0],geo[1],geo[2],dir.num_fiber*3));
for(unsigned int i = 0,ptr = 0;i < dir.num_fiber;++i)
for(unsigned int j = 0;j < 3;++j)
for(unsigned int index = 0;index < geo.size();++index,++ptr)
Expand All @@ -106,7 +106,7 @@ int exp(void)
std::cout << "Invalid fiber index. The maximum fiber per voxel is " << (int) dir.num_fiber << std::endl;
continue;
}
fibers.resize(image::geometry<4>(geo[0],geo[1],geo[2],3));
fibers.resize(tipl::geometry<4>(geo[0],geo[1],geo[2],3));
for(unsigned int j = 0,ptr = 0;j < 3;++j)
for(unsigned int index = 0;index < geo.size();++index,++ptr)
if(dir.get_fa(index,dir_index))
Expand All @@ -115,7 +115,7 @@ int exp(void)
gz_nifti nifti_header;
if(trans) //QSDR condition
nifti_header.set_LPS_transformation(trans,fibers.geometry());
image::flip_xy(fibers);
tipl::flip_xy(fibers);
nifti_header << fibers;
nifti_header.set_voxel_size(vs);
nifti_header.save_to_file(file_name_stat.c_str());
Expand All @@ -133,13 +133,13 @@ int exp(void)
std::cout << "expected dimension: " << geo[0] << " by " << geo[1] << " by " << geo[2] << std::endl;
continue;
}
image::basic_image<float,3> data(geo);
tipl::image<float,3> data(geo);
std::copy(volume,volume+geo.size(),data.begin());
gz_nifti nifti_header;

if(trans) //QSDR condition
nifti_header.set_LPS_transformation(trans,data.geometry());
image::flip_xy(data);
tipl::flip_xy(data);
nifti_header << data;
nifti_header.set_voxel_size(vs);
nifti_header.save_to_file(file_name_stat.c_str());
Expand Down
2 changes: 1 addition & 1 deletion cmd/qc.cpp
Expand Up @@ -26,7 +26,7 @@ std::string quality_check_src_files(QString dir)
}
unique_prog(false);
// output image dimension
out << image::vector<3,int>(handle.voxel.dim.begin()) << "\t";
out << tipl::vector<3,int>(handle.voxel.dim.begin()) << "\t";
// output image resolution
out << handle.voxel.vs << "\t";
// output DWI count
Expand Down
6 changes: 3 additions & 3 deletions cmd/rec.cpp
Expand Up @@ -3,7 +3,7 @@
#include <iostream>
#include <iterator>
#include <string>
#include "image/image.hpp"
#include "tipl/tipl.hpp"
#include "libs/dsi/image_model.hpp"
#include "dsi_interface_static_link.h"
#include "mapping/fa_template.hpp"
Expand Down Expand Up @@ -54,7 +54,7 @@ int rec(void)
std::cout << "Invalid transfformation matrix." <<std::endl;
return 1;
}
image::transformation_matrix<double> affine;
tipl::transformation_matrix<double> affine;
affine.load_from_transform(T.begin());
std::cout << "rotating images" << std::endl;
handle->rotate(handle->voxel.dim,affine);
Expand Down Expand Up @@ -222,7 +222,7 @@ int rec(void)
gz_nifti header;
if(header.load_from_file(mask_file.c_str()))
{
image::basic_image<unsigned char,3> external_mask;
tipl::image<unsigned char,3> external_mask;
header.toLPS(external_mask);
if(external_mask.geometry() != handle->voxel.dim)
std::cout << "In consistent the mask dimension...using default mask" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion cmd/src.cpp
Expand Up @@ -2,7 +2,7 @@
#include <iostream>
#include <iterator>
#include <string>
#include "image/image.hpp"
#include "tipl/tipl.hpp"
#include "dicom/dwi_header.hpp"
#include "program_option.hpp"

Expand Down

0 comments on commit d43f4cb

Please sign in to comment.