In [ ]:
import lib.django.djff.models as dm
def prioritize_images(list_of_images, priority=5):
id_list = [x.id for x in list(list_of_images)]
for image_id in id_list:
prior = dm.PriorityManualImage()
prior.image_id = image_id
prior.priority = priority
prior.save()
all_data_images = dm.Image.objects.filter(is_cal_image=False)
In [13]:
## EXAMPLE: Get all images from experiment 11.
xp_11_images = all_data_images.filter(xp_id=156)
In [3]:
## EXAMPLE: Get all images from CJRs 140, 158, and 161.
selected_cjrs_images = all_data_images.filter(cjr_id__in=[140,158,161])
In [4]:
## EXAMPLE: Get all images from experiments 11 and 94.
selected_xps_images = all_data_images.filter(xp_id__in=[11,94])
In [26]:
## EXAMPLE: Get every 13th image from experiment 94.
xp_94_images = all_data_images.filter(xp_id__in=[156,157,158,159,162])
every_13th = list(xp_94_images)[::5]
print "{} / {} = {}".format(len(every_13th),
xp_94_images.count(),
float(xp_94_images.count()) / len(every_13th))
After you select the images, you'll need to actually prioritize them using the function defined in the first cell of this notebook: prioritize_images
.
The default priority is 5. Lower numbered priorities (e.g. 3) will run before higher numbered priorities (e.g. 10).
In [27]:
## This can take some time.
prioritize_images(every_13th, priority=100) # very low priority
#prioritize_images(every_13th) # very low priority
In [28]:
## EXAMPLE: Find out how many images are currently prioritized.
print dm.PriorityManualImage.objects.count()
In [16]:
## EXAMPLE: Find out which CJRs contain prioritized images.
cjr_list = [x.image.cjr_id for x in dm.PriorityManualImage.objects.all()]
print set(cjr_list)
In [ ]:
## EXAMPLE: Find out the proportion of images for experiment 70 that are tagged.
images_in_xp_70 = dm.Image.objects.filter(xp_id=70).count()
tags_for_xp_70 = dm.ManualTag.objects.filter(image__xp_id=70).count()
print "{} / {} = {}".format(tags_for_xp_70, images_in_xp_70, float(tags_for_xp_70) / images_in_xp_70)
In [11]:
### WARNING ###
### THIS WILL DELETE ALL OF YOUR PRIORITIES ###
### WARNING ###
dm.PriorityManualImage.objects.all().delete()
In [ ]:
## EXAMPLE: Delete the priorities for experiment 11, if any.
dm.PriorityManualImage.objects.filter(image__xp_id=11).delete()