WCP¶
Support is provided for reading data from files recorded using WinWCP.
The WcpFile
class implements Myokit’s shared
myokit.formats.SweepSource
interface.
- class myokit.formats.wcp.WcpFile(path)¶
Represents a read-only WinWCP file (
.wcp
), stored atpath
.Only files in the newer file format version 9 can be read. This version of the format was introduced in 2010. New versions of WinWCP can read older files and will convert them to the new format automatically when opened.
WinWCP is a tool for recording electrophysiological data written by John Dempster of Strathclyde University. For more information, see https://documentation.help/WinWCP-V5.3.8/IDH_Topic750.htm
WinWCP files contain a number of records
NR
, each containing data fromNC
channels. Every channel has the same length,NP
samples. Sampling happens at a fixed sampling rate.When a
WcpFile
is created, the file atpath
is read in its entirety and the file handle is closed. No try-catch orwith
statements are required.- channel(channel_id, join_sweeps=False)¶
Returns the data for a single channel, identified by integer or string
channel_id
.With
join_sweeps=False
, the data is returned as a tuple(times, sweeps)
wheretimes
andsweeps
are 2d numpy arrays indexed so thattimes[i][j]
is thej
-th time point for sweepi
.If
join_sweeps=True
the sweeps are joined together, and a tuple(times, values)
is returnedtimes
andvalues
are 1d arrays.
- channel_count()¶
Returns the number of channels.
- channel_names(index=None)¶
Returns the names of all channels or the name of a specific channel
index
.
- channel_units(index=None)¶
Returns the units (as
myokit.Unit
) of all channels or the units of a specific channelindex
.
- channels()¶
Deprecated alias of
channel_count()
.
- da_count()¶
Returns the available number of reconstructed D/A output channels.
This should return 0 if D/A channels are not supported.
- equal_length_sweeps()¶
Returns
True
only if each sweep in this source has the same length.
- filename()¶
Returns this file’s name.
- info()¶
Deprecated alias of
meta_str()
- log(join_sweeps=False, use_names=False, include_da=True)¶
Returns a
myokit.DataLog
containing the data from all channels.The log will have a single entry
time
corresponding to the time of the first sweep ifjoin_sweeps
isFalse
, or the time of all points whenjoin_sweeps
isTrue
.Names will have a systematic form
i_sweep.i_channel.label
, for example0.1.channel
for sweep 0 of recorded channel 1, or3.0.da
for sweep 3 of reconstructed D/A output 0. These can also be accessed using the syntaxlog['channel', 1, 0]
andlog['da', 0, 3]
.To obtain a log with the user-specified names from the source instead, set
use_names
toTrue
. This will result in names such as0.IN 1
or3.Cmd 0
.To exclude D/A signal reconstructions, set
include_da
toFalse
.A call with
join_sweeps=False
on a source whereequal_length_sweeps()
returnsFalse
will raise aValueError
.
- matplotlib_figure()¶
Creates and returns a matplotlib figure with this file’s data.
- meta_str(verbose=False)¶
Optional method that returns a multi-line string with unstructured meta data about the source and its contents.
Will return
None
if no such string is available.
- myokit_log()¶
Deprecated method. Please use
WcpFile.log(use_names=True)
instead.
- path()¶
Returns the path to this file.
- plot()¶
Deprecated method, please use
matplotlib_figure()
instead.Creates and shows a matplotlib figure of all data in this file.
- record_count()¶
Alias of
sweep_count()
.
- records()¶
Deprecated alias of
record_count()
.
- sample_count()¶
Returns the number of samples in each channel.
- sweep_count()¶
Returns the number of sweeps.
Note that a source with zero recorded channels may still report a non-zero number of sweeps if it can provide D/A outputs.
Similarly, formats like WCP can report zero sweeps but have a non-zero channel count (if no data was recorded).
- time_unit()¶
Returns the time unit used in this source.
- times()¶
Returns the time points sampled at.
- values(record, channel)¶
Returns the values of channel
channel
, recorded in recordrecord
.
- version()¶
Returns this file’s version, as a string.