aqnwb 0.4.0
Loading...
Searching...
No Matches
Subject.hpp
Go to the documentation of this file.
1#pragma once
2
3// Common STL includes
4#include <memory>
5#include <optional>
6#include <string>
7#include <vector>
8// Base AqNWB includes for IO and RegisteredType
9#include "io/BaseIO.hpp"
10#include "io/ReadIO.hpp"
12// Include for parent type
14// Include for the namespace schema header
15#include "spec/core.hpp"
16
17namespace AQNWB::NWB
18{
19
25{
26public:
28
29
36 {
38 std::optional<std::string> age = std::nullopt;
41 std::optional<std::string> ageReference = std::nullopt;
43 std::optional<std::string> dateOfBirth = std::nullopt;
45 std::optional<std::string> description = std::nullopt;
47 std::optional<std::string> genotype = std::nullopt;
49 std::optional<std::string> sex = std::nullopt;
51 std::optional<std::string> species = std::nullopt;
53 std::optional<std::string> strain = std::nullopt;
56 std::optional<std::string> subjectId = std::nullopt;
58 std::optional<std::string> weight = std::nullopt;
59
65 SubjectSpec& withAge(std::string value)
66 {
67 age = std::move(value);
68 return *this;
69 }
70
77 SubjectSpec& withAgeReference(std::string value)
78 {
79 ageReference = std::move(value);
80 return *this;
81 }
82
88 SubjectSpec& withDateOfBirth(std::string value)
89 {
90 dateOfBirth = std::move(value);
91 return *this;
92 }
93
99 SubjectSpec& withDescription(std::string value)
100 {
101 description = std::move(value);
102 return *this;
103 }
104
110 SubjectSpec& withGenotype(std::string value)
111 {
112 genotype = std::move(value);
113 return *this;
114 }
115
121 SubjectSpec& withSex(std::string value)
122 {
123 sex = std::move(value);
124 return *this;
125 }
126
132 SubjectSpec& withSpecies(std::string value)
133 {
134 species = std::move(value);
135 return *this;
136 }
137
143 SubjectSpec& withStrain(std::string value)
144 {
145 strain = std::move(value);
146 return *this;
147 }
148
155 SubjectSpec& withSubjectId(std::string value)
156 {
157 subjectId = std::move(value);
158 return *this;
159 }
160
166 SubjectSpec& withWeight(std::string value)
167 {
168 weight = std::move(value);
169 return *this;
170 }
171 };
172
179 static std::shared_ptr<Subject> create(std::shared_ptr<IO::BaseIO> io);
180
184 virtual ~Subject() override {}
185
191 Status initialize(const SubjectSpec& subjectSpec);
192
193 // Define read methods
195 readAge,
196 recordAge,
197 std::string,
198 "age",
199 "Age of subject. Can be supplied instead of date_of_birth.")
200
204 std::string,
205 "date_of_birth",
206 "Date of birth of subject. Can be supplied instead of age.")
207
210 std::string,
211 "description",
212 "Description of subject and where subject came from "
213 "(e.g. - breeder - if animal).")
214
217 std::string,
218 "genotype",
219 "Genetic strain. If absent - assume Wild Type (WT).")
220
222 readSex, recordSex, std::string, "sex", "Gender of subject.")
223
225 readSpecies, recordSpecies, std::string, "species", "Species of subject.")
226
228 readStrain, recordStrain, std::string, "strain", "Strain of subject.")
229
233 std::string,
234 "subject_id",
235 "ID of animal/person used/participating in experiment (lab convention).")
236
239 std::string,
240 "weight",
241 "Weight at time of experiment - at time of surgery and "
242 "at other important times.")
243
246 std::string,
247 "age/reference",
248 "Age is with reference to this event. Can be birth or gestational. If "
249 "reference is omitted - birth is implied.")
250
251protected:
256 explicit Subject(std::shared_ptr<IO::BaseIO> io);
257
263 Subject(const std::string& path, std::shared_ptr<AQNWB::IO::BaseIO> io);
264};
265
266} // namespace AQNWB::NWB
AQNWB::Types::Status Status
Definition BaseIO.hpp:21
#define REGISTER_SUBCLASS(T, BASE, NAMESPACE)
Macro to register a subclass with the RegisteredType class registry.
Definition RegisteredType.hpp:547
#define DEFINE_ATTRIBUTE_FIELD(name, default_type, fieldPath, description)
Defines a lazy-loaded attribute field accessor function.
Definition RegisteredType.hpp:580
#define DEFINE_DATASET_FIELD(readName, writeName, default_type, fieldPath, description)
Defines a lazy-loaded dataset field accessor function.
Definition RegisteredType.hpp:619
An abstract data type for a generic container storing collections of data and metadata....
Definition NWBContainer.hpp:25
Status initialize()
Initialize the object.
Definition NWBContainer.cpp:17
NWBContainer(const std::string &path, std::shared_ptr< AQNWB::IO::BaseIO > io)
Constructor.
Definition NWBContainer.cpp:11
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordGenotype(bool reset=false)
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readSpecies() const
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordDescription(bool reset=false)
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordAge(bool reset=false)
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordStrain(bool reset=false)
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readWeight() const
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordDateOfBirth(bool reset=false)
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordSpecies(bool reset=false)
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readDescription() const
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readStrain() const
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordSubjectId(bool reset=false)
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readSubjectId() const
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readGenotype() const
Subject(std::shared_ptr< IO::BaseIO > io)
Constructor for Subject.
Definition Subject.cpp:12
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readAge() const
static std::shared_ptr< Subject > create(const std::string &path, std::shared_ptr< AQNWB::IO::BaseIO > io)
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::AttributeField, VTYPE > > readAgeReference() const
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordWeight(bool reset=false)
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readSex() const
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordSex(bool reset=false)
virtual ~Subject() override
Virtual destructor.
Definition Subject.hpp:184
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readDateOfBirth() const
The namespace for IO components of AqNWB.
Namespace for all classes related to the NWB data standard.
const std::string namespaceName
Definition core.hpp:21
The main namespace for AqNWB.
Definition Channel.hpp:11
Metadata about the experimental subject.
Definition Subject.hpp:36
std::optional< std::string > species
Species of subject.
Definition Subject.hpp:51
SubjectSpec & withSex(std::string value)
Set the biological sex of the subject.
Definition Subject.hpp:121
std::optional< std::string > strain
Strain of subject.
Definition Subject.hpp:53
std::optional< std::string > dateOfBirth
Date of birth of subject as iso formatted date string.
Definition Subject.hpp:43
SubjectSpec & withStrain(std::string value)
Set the strain of the subject.
Definition Subject.hpp:143
std::optional< std::string > subjectId
ID of animal/person used/participating in experiment (lab convention).
Definition Subject.hpp:56
std::optional< std::string > description
Description of subject and where subject came from.
Definition Subject.hpp:45
SubjectSpec & withWeight(std::string value)
Set the weight of the subject.
Definition Subject.hpp:166
std::optional< std::string > ageReference
Age is with reference to this event. Can be ‘birth’ or ‘gestational’. If reference is omitted,...
Definition Subject.hpp:41
SubjectSpec & withAge(std::string value)
Set the age of the subject.
Definition Subject.hpp:65
SubjectSpec & withDateOfBirth(std::string value)
Set the date of birth of the subject.
Definition Subject.hpp:88
std::optional< std::string > age
Age of subject (e.g., "P90D" for 90 days post-natal).
Definition Subject.hpp:38
SubjectSpec & withSpecies(std::string value)
Set the species of the subject.
Definition Subject.hpp:132
std::optional< std::string > weight
Weight at time of experiment.
Definition Subject.hpp:58
std::optional< std::string > sex
Biological sex of subject.
Definition Subject.hpp:49
SubjectSpec & withGenotype(std::string value)
Set the genotype of the subject.
Definition Subject.hpp:110
std::optional< std::string > genotype
Genetic strain. If absent, assume Wild Type (WT).
Definition Subject.hpp:47
SubjectSpec & withDescription(std::string value)
Set the description of the subject.
Definition Subject.hpp:99
SubjectSpec & withSubjectId(std::string value)
Set the ID of the subject.
Definition Subject.hpp:155
SubjectSpec & withAgeReference(std::string value)
Set the age reference event of the subject.
Definition Subject.hpp:77