forked from frankyeh/DSI-Studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_image.h
148 lines (122 loc) · 3.82 KB
/
view_image.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#ifndef VIEW_IMAGE_H
#define VIEW_IMAGE_H
#include <QMainWindow>
#include <QGraphicsScene>
#include "TIPL/tipl.hpp"
#include "libs/gzip_interface.hpp"
namespace Ui {
class view_image;
}
class QTableWidget;
class TableKeyEventWatcher : public QObject {
Q_OBJECT
using QObject::QObject;
private:
QTableWidget* table;
bool eventFilter(QObject * receiver, QEvent * event) override;
public:
TableKeyEventWatcher(QTableWidget* table);
Q_SIGNAL void DeleteRowPressed(int row);
};
class view_image : public QMainWindow
{
Q_OBJECT
std::shared_ptr<TableKeyEventWatcher> table_event;
public:
QString file_name,original_file_name;
QStringList file_names;
gz_nifti nifti;
explicit view_image(QWidget *parent = nullptr);
~view_image();
bool open(QStringList file_name);
bool eventFilter(QObject *obj, QEvent *event);
public:
std::vector<std::string> command_list;
std::vector<std::string> param_list;
bool command(std::string cmd,std::string param1 = std::string());
private:
void update_other_images(void);
bool has_flip_x(void);
bool has_flip_y(void);
private slots:
void DeleteRowPressed(int row);
void show_info(QString info);
void show_image(bool update_others);
void init_image(void);
void update_overlay_menu(void);
void set_overlay(void);
void on_action_Save_as_triggered();
void on_actionSet_Translocation_triggered();
void on_actionSet_Transformation_triggered();
void change_contrast();
void on_min_slider_sliderMoved(int position);
void on_min_valueChanged(double arg1);
void on_max_slider_sliderMoved(int position);
void on_max_valueChanged(double arg1);
void on_AxiView_clicked();
void on_CorView_clicked();
void on_SagView_clicked();
void on_slice_pos_valueChanged(int value);
void on_actionSave_triggered();
void on_dwi_volume_valueChanged(int value);
void run_action();
void run_action2();
void on_type_currentIndexChanged(int index);
void on_zoom_valueChanged(double arg1);
void on_info_cellChanged(int row, int column);
void on_info_cellDoubleClicked(int row, int column);
void on_mat_images_currentIndexChanged(int index);
private:
Ui::view_image *ui;
private:
tipl::image<3,unsigned char,tipl::buffer_container> I_uint8;
tipl::image<3,unsigned short,tipl::buffer_container> I_uint16;
tipl::image<3,unsigned int,tipl::buffer_container> I_uint32;
tipl::image<3,float,tipl::buffer_container> I_float32;
enum {uint8 = 0,uint16 = 1,uint32 = 2,float32 = 3} data_type = uint8;
tipl::shape<3> shape;
bool is_mni = false;
tipl::vector<3,float> vs;
tipl::matrix<4,4> T;
template <typename T>
void apply(T&& fun)
{
switch(data_type)
{
case uint8:fun(I_uint8);return;
case uint16:fun(I_uint16);return;
case uint32:fun(I_uint32);return;
case float32:fun(I_float32);return;
}
}
private:
gz_mat_read mat;
void read_mat_info(void);
bool read_mat_image(void);
void write_mat_image(void);
bool read_mat(void);
private: //overlay
std::vector<size_t> overlay_images;
std::vector<bool> overlay_images_visible;
size_t this_index = 0;
private:
std::vector<std::vector<unsigned char> > dwi_volume_buf;
size_t cur_dwi_volume = 0;
private:// batch processing
/*
std::vector<tipl::image<3> > other_data;
std::vector<std::string> other_file_name;
std::vector<tipl::vector<3,float> > other_vs;
std::vector<tipl::matrix<4,4> > other_T;
std::vector<bool> other_is_mni;
*/
private: // visualization
bool no_update = true;
tipl::value_to_color<float> v2c;
unsigned char cur_dim = 2;
int slice_pos[3];
QGraphicsScene source;
QImage source_image;
std::string error_msg;
};
#endif // VIEW_IMAGE_H