Brain forms

This module defines the forms necessary to perform the QC on the slides/scenes. The user can rearrange, edit, and hide scenes with these forms.

class brain.forms.AnimalChoiceField(queryset, *, empty_label='---------', required=True, widget=None, label=None, initial=None, help_text='', to_field_name=None, limit_choices_to=None, blank=False, **kwargs)

Bases: ModelChoiceField

A simple class that returns the animal name.

label_from_instance(obj)

Convert objects into strings and generate the labels for the choices presented by this object. Subclasses can override this method to customize the display of the choices.

class brain.forms.AnimalForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)

Bases: Form

Sets up fields for the select dropdown menu in forms. Animals are sorted by name.

class Meta

Bases: object

fields = ('prep_id',)
base_fields = {'prep_id': <django.forms.models.ModelChoiceField object>}
declared_fields = {'prep_id': <django.forms.models.ModelChoiceField object>}
property media

Return all media required to render the widgets on this form.

class brain.forms.TifInlineFormset(data=None, files=None, instance=None, save_as_new=False, prefix=None, queryset=None, **kwargs)

Bases: BaseInlineFormSet

This class defines the form for the subsets of scenes for a slide. This is where the work is done for rearranging and editing the scenes.

save_existing(form, instance, commit=True)

This is called when updating an instance.

Parameters
  • form – Form object.

  • instance – slide CZI TIFF object.

  • commit – A boolean stating if the object should be committed.

brain.forms.create_scene(tifs, scene_number)

Helper method to create a scene.

Parameters
  • tifs – A list of TIFFs.

  • scene_number – An integer used to find the nearest neighbor

brain.forms.find_closest_neighbor(FK_slide_id, scene_number)
Helper method to get the nearest scene. Look first at the preceding tifs,

if nothing is there, go for the one just after.

Parameters
  • FK_slide_id – primary key of the slide

  • scene_number – scene number. 1 per set of 3 channels

Returns

set of tifs

brain.forms.remove_scene(FK_slide_id, deletes, scene_number)

Helper method to remove a scene.

Parameters
  • FK_slide_id – An integer primary key of the slide.

  • deletes – An integer defining how many scenes to delete.

  • scene_number – An integer used to find the nearest neighbor

brain.forms.repeat_scene(FK_slide_id, inserts, scene_number)

Helper method to duplicate a scene.

Parameters
  • FK_slide_id – An integer primary key of the slide.

  • inserts – An integer defining how many scenes to insert.

  • scene_number – An integer used to find the nearest neighbor

brain.forms.save_slide_model(self, request, obj, form, change)

This method overrides the slide save method.

Parameters
  • request – The HTTP request.

  • obj – The slide object.

  • form – The form object.

  • change – unused variable, shows if the form has changed.

brain.forms.scene_reorder(FK_slide_id)

Helper method to reorder a set of scenes.

Parameters

FK_slide_id – An integer for the primary key of the slide.

brain.forms.set_end(FK_slide_id, scene_number)

Helper method to set a scene as the very last one in a brain.

Parameters
  • FK_slide_id – An integer for the primary key of the slide.

  • scene_number – An integer used to find the nearest neighbor.

brain.forms.set_scene_active_inactive(FK_slide_id, scene_number, active)

Helper method to set a scene as active.

Parameters
  • FK_slide_id – An integer for the primary key of the slide.

  • scene_number – An integer used to find the nearest neighbor.

  • active – A boolean defining whether to set the scene active or inactive