research.models package

Module contents

Definition of the app’s models. For an illustration of the relationship between the different models, see the Overview.

Submodules

research.models.choices module

Subclasses of the ChoiceEnum class used to represent raw and human-readable values for choices within the research.models module.

class research.models.choices.DominantHand

Bases: pylabber.utils.utils.ChoiceEnum

An Enum representing supported dominant hand options.

A = 'Ambidextrous'
L = 'Left'
R = 'Right'
class research.models.choices.Gender

Bases: pylabber.utils.utils.ChoiceEnum

An Enum representing supported gender options.

CIS = 'Cisgender'
OTHER = 'Other'
TRANS = 'Transgender'
class research.models.choices.Sex

Bases: pylabber.utils.utils.ChoiceEnum

An Enum representing supported sex options.

F = 'Female'
M = 'Male'
U = 'Other'

research.models.group module

Definition of the Group model.

class research.models.group.Group(*args, **kwargs)

Bases: django_extensions.db.models.TitleDescriptionModel, django_extensions.db.models.TimeStampedModel

Represents a unique study group (i.e. a grouping of subjects according to some experimental design in the context of a study).

mri_scan_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

study

The study associated with this experimental group.

research.models.study module

Definition of the Study model.

class research.models.study.Study(*args, **kwargs)

Bases: django_extensions.db.models.TitleDescriptionModel, django_extensions.db.models.TimeStampedModel

Represents a single study in the database.

collaborators

Researchers collaborating on this study.

get_absolute_url()

Returns the canonical URL for this instance.

References

Returns:URL
Return type:str
group_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

image

An optional image to supplement the description.

n_subjects

Returns the number of subjects associated with this study.

Returns:Number of subjects associated with this study
Return type:int
procedures

The experimental procedures associated with this study.

query_associated_subjects() → django.db.models.query.QuerySet

Returns a queryset of subjects associated with this study.

See also

Returns:Subjects associated with this study
Return type:models.QuerySet
subject_set

Returns a queryset of subjects associated with this study.

Returns:Subjects associated with this study
Return type:models.QuerySet
subjects

Subjects associated with this study. This field is currently not used, but kept because in the future it might be used for “caching” associated subjects to save queries.

research.models.subject module

Definition of the Subject model.

class research.models.subject.Subject(*args, **kwargs)

Bases: django_extensions.db.models.TimeStampedModel

Represents a single research subject. Any associated data model should be associated with this model.

BIDS_DIR_TEMPLATE = 'sub-{pk}'
build_bids_directory(force: bool = False, persistent: bool = True, progressbar: bool = False, progressbar_position: int = 0)
custom_attributes

Custom attributes dictionary.

date_of_birth

Subject’s date of birth.

dominant_hand

Subject’s dominant hand.

first_name

Subject’s first name.

gender

Subject’s gender.

get_absolute_url()

Returns the canonical URL for this instance.

References

Returns:URL
Return type:str
get_bids_directory() → pathlib.Path
get_dominant_hand_display(*, field=<django.db.models.fields.CharField: dominant_hand>)
get_full_name() → str

Returns a formatted string with the subject’s full name (first name and then last name).

Returns:Subject’s full name
Return type:str
get_gender_display(*, field=<django.db.models.fields.CharField: gender>)
get_personal_information() → pandas.core.series.Series

Temporary method to use an external table to retrieve subject personal information.

Returns:Subject personal information
Return type:pd.Series
get_questionnaire_data()

A method to link between a subject to it’s questionnaire data.

Returns:Subject and Questionnaire information.
Return type:pd.Series
get_raw_information() → pandas.core.series.Series

Temporary method to use an external table to retrieve subject information.

Returns:Subject information
Return type:pd.Series
get_sex_display(*, field=<django.db.models.fields.CharField: sex>)
id_number

Some representative ID number unique to this subject.

last_name

Subject’s last name.

mri_session_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

query_measurements() → django.db.models.query.QuerySet
query_procedures() → django.db.models.query.QuerySet
query_run_set() → django.db.models.query.QuerySet
query_scores(analysis: Union[django_analyses.models.analysis.Analysis, Iterable[django_analyses.models.analysis.Analysis]] = None, analysis_title: Union[str, Iterable[str]] = None, analysis_version: Union[django_analyses.models.analysis_version.AnalysisVersion, Iterable[django_analyses.models.analysis_version.AnalysisVersion]] = None, analysis_version_title: Union[str, Iterable[str]] = None, atlas=None, atlas_title: Union[str, Iterable[str]] = None, metric=None, metric_title: Union[str, Iterable[str]] = None, region=None, region_title: Union[str, Iterable[str]] = None, region_index: Union[int, Iterable[int]] = None, hemisphere: str = None) → django.db.models.query.QuerySet
query_studies() → django.db.models.query.QuerySet

Returns a queryset of Study instances this subject has data associated with.

Returns:Associated studies
Return type:models.QuerySet
query_study_groups() → django.db.models.query.QuerySet
save(*args, **kwargs)

Overrides the model’s save() method to process custom attributes.

Hint

For more information, see Django’s documentation on overriding model methods.

sex

Subject’s sex.

study_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

research.models.procedure module

Definition of the Procedure model.

class research.models.procedure.Procedure(*args, **kwargs)

Bases: django_extensions.db.models.TitleDescriptionModel

Represents an experimental procedure.

add_event(event: research.models.event.Event, index: int = None)

Performs an event addition.

events

Represents an ordered list of events in a procedure.

get_absolute_url()

Returns the canonical URL for this instance.

References

Returns:URL
Return type:str
max_index

Returns the maximal index field value of any associated ProcedureStep instances. If there aren’t any, returns -1.

Returns:Maximal step index, or -1
Return type:int
step_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

study_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

research.models.event module

Definition of the Event model.

class research.models.event.Event(*args, **kwargs)

Bases: django_extensions.db.models.TitleDescriptionModel

Represents an event as a part of a procedure.

get_absolute_url()

Returns the canonical URL for this instance.

References

Returns:URL
Return type:str
measurementdefinition

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

procedure_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

procedurestep_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

task

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

research.models.task module

Definition of the Task model.

class research.models.task.Task(*args, **kwargs)

Bases: research.models.event.Event

Represents an experimental task.

event_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

event_ptr_id
get_absolute_url()

Returns the canonical URL for this instance.

References

Returns:URL
Return type:str

research.models.measurement_definition module

Definition of the MeasurementDefinition model.

class research.models.measurement_definition.MeasurementDefinition(*args, **kwargs)

Bases: research.models.event.Event

Represents an experimental measurement definition.

content_type

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_type_id
event_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

event_ptr_id
get_absolute_url()

Returns the canonical URL for this instance.

References

Returns:URL
Return type:str
get_instance_set() → django.db.models.query.QuerySet

Returns a queryset of collected measurements associated with this measurements definition.

Returns:Collected data instances
Return type:models.QuerySet
instance_set

Returns a queryset of collected measurements associated with this measurements definition.

Returns:Collected data instances
Return type:models.QuerySet
mri_session_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

query_associated_studies() → django.db.models.query.QuerySet

research.models.validators module

Validators for django fields within the research.models module.

research.models.validators.not_future(value)