MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
fiff_digitizer_data.cpp
Go to the documentation of this file.
1//=============================================================================================================
37//=============================================================================================================
38// INCLUDES
39//=============================================================================================================
40
41#include "fiff_digitizer_data.h"
43#include "../fiff_dig_point.h"
44#include <iostream>
45
46#ifndef TRUE
47#define TRUE 1
48#endif
49
50#ifndef FALSE
51#define FALSE 0
52#endif
53
54#define FREE_43(x) if ((char *)(x) != Q_NULLPTR) free((char *)(x))
55
56#define MALLOC_43(x,t) (t *)malloc((x)*sizeof(t))
57
58#define FREE_CMATRIX_43(m) mne_free_cmatrix_43((m))
59
60void mne_free_cmatrix_43(float **m)
61{
62 if (m) {
63 FREE_43(*m);
64 FREE_43(m);
65 }
66}
67
68//=============================================================================================================
69// USED NAMESPACES
70//=============================================================================================================
71
72using namespace FIFFLIB;
73
74//=============================================================================================================
75// DEFINE MEMBER METHODS
76//=============================================================================================================
77
79: head_mri_t(Q_NULLPTR)
80, head_mri_t_adj(Q_NULLPTR)
81, coord_frame(FIFFV_COORD_UNKNOWN)
82, npoint(0)
83, mri_fids(Q_NULLPTR)
84, nfids(0)
85, show(FALSE)
86, show_minimal(FALSE)
87, dist(Q_NULLPTR)
88, closest(Q_NULLPTR)
89, closest_point(Q_NULLPTR)
90, dist_valid(FALSE)
91{
92}
93
94//=============================================================================================================
95
97: head_mri_t(p_FiffDigitizerData.head_mri_t)
98, head_mri_t_adj(p_FiffDigitizerData.head_mri_t_adj)
99, points(p_FiffDigitizerData.points)
100, coord_frame(p_FiffDigitizerData.coord_frame)
101, active(p_FiffDigitizerData.active)
102, discard(p_FiffDigitizerData.discard)
103, npoint(p_FiffDigitizerData.npoint)
104, mri_fids(p_FiffDigitizerData.mri_fids)
105, nfids(p_FiffDigitizerData.nfids)
106, show(p_FiffDigitizerData.show)
107, show_minimal(p_FiffDigitizerData.show_minimal)
108, dist(p_FiffDigitizerData.dist)
109, closest(p_FiffDigitizerData.closest)
110, closest_point(p_FiffDigitizerData.closest_point)
111, dist_valid(p_FiffDigitizerData.dist_valid)
112{
113}
114
115//=============================================================================================================
116
118: head_mri_t(Q_NULLPTR)
119, head_mri_t_adj(Q_NULLPTR)
120, coord_frame(FIFFV_COORD_UNKNOWN)
121, npoint(0)
122, mri_fids(Q_NULLPTR)
123, nfids(0)
124, show(FALSE)
125, show_minimal(FALSE)
126, dist(Q_NULLPTR)
127, closest(Q_NULLPTR)
128, closest_point(Q_NULLPTR)
129, dist_valid(FALSE)
130{
131 // Open the io device
132 FiffStream::SPtr t_pStream(new FiffStream(&p_IODevice));
133 bool open_here = false;
134
135 //Open if the device and stream have not been openend already
136 if (!t_pStream->device()->isOpen()) {
137 if(!t_pStream->open()) {
138 qWarning() << "Warning in FiffDigitizerData::FiffDigitizerData - Could not open the didigitzer data file"; // ToDo throw error
139 return;
140 }
141
142 open_here = true;
143 }
144
145 // If device is open read the data
146 if(!t_pStream->read_digitizer_data(t_pStream->dirtree(), *this)) {
147 qWarning() << "Warning in FiffDigitizerData::FiffDigitizerData - Could not read the FiffDigitizerData"; // ToDo throw error
148 }
149
150 // If stream has been opened in this function also close here again
151 if(open_here) {
152 t_pStream->close();
153 }
154}
155
156//=============================================================================================================
157
159{
160 FREE_43(head_mri_t);
161 FREE_43(head_mri_t_adj);
162 FREE_43(dist);
163 FREE_43(closest);
164 FREE_CMATRIX_43(closest_point);
165 FREE_43(mri_fids);
166}
167
168//=============================================================================================================
169
171{
172 std::cout << "Number of digitizer points: " << points.size() << "\n";
173
174 switch(coord_frame){
175 case FIFFV_COORD_MRI:
176 std::cout << "Coord. Frame: FIFFV_COORD_MRI \n";
177 break;
178 case FIFFV_COORD_HEAD:
179 std::cout << "Coord. Frame: FIFFV_COORD_HEAD \n";
180 break;
181 }
182
183 for (auto& point : points){
184 if (point.kind == FIFFV_POINT_HPI){
185 std::cout << "HPI Point " << point.ident << " - " << point.r[0] << ", " << point.r[1] << ", " << point.r[2] << "\n";
186 }
187 }
188
189 std::cout << "Number of MRI fiducials: " << nfids << "\n";
190
191 if (head_mri_t){
192
193 }
194}
FiffCoordTransOld class declaration.
FiffDigitizerData class declaration.
Digitization points container and description.
FIFF File I/O routines.
QSharedPointer< FiffStream > SPtr