@@ -131,28 +131,77 @@ def __init__(
131
131
verbose = None ,
132
132
):
133
133
self ._set_times (np .array (times ))
134
- self .pos = np .array (pos )
135
- self .amplitude = np .array (amplitude )
136
- self .ori = np .array (ori )
137
- self .gof = np .array (gof )
138
- self .name = name
139
- self .conf = dict ()
134
+ self ._pos = np .array (pos )
135
+ self ._amplitude = np .array (amplitude )
136
+ self ._ori = np .array (ori )
137
+ self ._gof = np .array (gof )
138
+ self ._name = name
139
+ self ._conf = dict ()
140
140
if conf is not None :
141
141
for key , value in conf .items ():
142
- self .conf [key ] = np .array (value )
143
- self .khi2 = np .array (khi2 ) if khi2 is not None else None
144
- self .nfree = np .array (nfree ) if nfree is not None else None
142
+ self ._conf [key ] = np .array (value )
143
+ self ._khi2 = np .array (khi2 ) if khi2 is not None else None
144
+ self ._nfree = np .array (nfree ) if nfree is not None else None
145
145
146
146
def __repr__ (self ): # noqa: D105
147
147
s = f"n_times : { len (self .times )} "
148
148
s += f", tmin : { np .min (self .times ):0.3f} "
149
149
s += f", tmax : { np .max (self .times ):0.3f} "
150
150
return f"<Dipole | { s } >"
151
151
152
+ @property
153
+ def pos (self ):
154
+ """The dipoles positions (m) in head coordinates."""
155
+ return self ._pos
156
+
157
+ @property
158
+ def amplitude (self ):
159
+ """The amplitude of the dipoles (Am)."""
160
+ return self ._amplitude
161
+
162
+ @property
163
+ def ori (self ):
164
+ """The dipole orientations (normalized to unit length)."""
165
+ return self ._ori
166
+
167
+ @property
168
+ def gof (self ):
169
+ """The goodness of fit."""
170
+ return self ._gof
171
+
172
+ @property
173
+ def name (self ):
174
+ """Name of the dipole."""
175
+ return self ._name
176
+
177
+ @name .setter
178
+ def name (self , name ):
179
+ _validate_type (name , str , "name" )
180
+ self ._name = name
181
+
182
+ @property
183
+ def conf (self ):
184
+ """Confidence limits in dipole orientation."""
185
+ return self ._conf
186
+
187
+ @property
188
+ def khi2 (self ):
189
+ """The χ^2 values for the fits."""
190
+ return self ._khi2
191
+
192
+ @property
193
+ def nfree (self ):
194
+ """The number of free parameters for each fit."""
195
+ return self ._nfree
196
+
152
197
@verbose
153
198
def save (self , fname , overwrite = False , * , verbose = None ):
154
199
"""Save dipole in a ``.dip`` or ``.bdip`` file.
155
200
201
+ The ``.[b]dip`` format is for :class:`mne.Dipole` objects, that is,
202
+ fixed-position dipole fits. For these fits, the amplitude, orientation,
203
+ and position vary as a function of time.
204
+
156
205
Parameters
157
206
----------
158
207
fname : path-like
@@ -203,7 +252,7 @@ def crop(self, tmin=None, tmax=None, include_tmax=True, verbose=None):
203
252
self .times , tmin , tmax , sfreq = sfreq , include_tmax = include_tmax
204
253
)
205
254
self ._set_times (self .times [mask ])
206
- for attr in ("pos " , "gof " , "amplitude " , "ori " , "khi2 " , "nfree " ):
255
+ for attr in ("_pos " , "_gof " , "_amplitude " , "_ori " , "_khi2 " , "_nfree " ):
207
256
if getattr (self , attr ) is not None :
208
257
setattr (self , attr , getattr (self , attr )[mask ])
209
258
for key in self .conf .keys ():
@@ -521,15 +570,23 @@ def ch_names(self):
521
570
return self .info ["ch_names" ]
522
571
523
572
@verbose
524
- def save (self , fname , verbose = None ):
525
- """Save dipole in FIF format.
573
+ def save (self , fname , * , overwrite = False , verbose = None ):
574
+ """Save fixed dipole in FIF format.
575
+
576
+ The ``.fif[.gz]`` format is for :class:`mne.DipoleFixed` objects, that is,
577
+ fixed-position and optionally fixed-orientation dipole fits. For these fits,
578
+ the amplitude (and optionally orientation) vary as a function of time,
579
+ but not the position.
526
580
527
581
Parameters
528
582
----------
529
583
fname : path-like
530
584
The name of the FIF file. Must end with ``'-dip.fif'`` or
531
585
``'-dip.fif.gz'`` to make it explicit that the file contains
532
586
dipole information in FIF format.
587
+ %(overwrite)s
588
+
589
+ .. versionadded:: 1.10.0
533
590
%(verbose)s
534
591
535
592
See Also
@@ -547,7 +604,7 @@ def save(self, fname, verbose=None):
547
604
),
548
605
(".fif" , ".fif.gz" ),
549
606
)
550
- _write_evokeds (fname , self , check = False )
607
+ _write_evokeds (fname , self , check = False , overwrite = overwrite )
551
608
552
609
def plot (self , show = True , time_unit = "s" ):
553
610
"""Plot dipole data.
@@ -595,6 +652,10 @@ def plot(self, show=True, time_unit="s"):
595
652
def read_dipole (fname , verbose = None ):
596
653
"""Read a dipole object from a file.
597
654
655
+ Non-fixed-position :class:`mne.Dipole` objects are usually saved in ``.[b]dip``
656
+ format. Fixed-position :class:`mne.DipoleFixed` objects are usually saved in
657
+ FIF format.
658
+
598
659
Parameters
599
660
----------
600
661
fname : path-like
0 commit comments