def view_task(request, cog_atlas_id=None):
    '''view_task returns a view to see a group of images associated with a particular cognitive atlas task.
    :param cog_atlas_id: statmaps.models.CognitiveAtlasTask the id for the task defined in the Cognitive Atlas
    '''
    from cogat_functions import get_task_graph

    # Get the cognitive atlas id
    if not cog_atlas_id:
        return search(request, error_message="Please search for a Cognitive Atlas task to see the task view.")

    try:
        task = CognitiveAtlasTask.objects.get(cog_atlas_id=cog_atlas_id)
    except __HOLE__:
        return search(request, error_message="Invalid search for Cognitive Atlas.")

    if task:
        images = StatisticMap.objects.filter(cognitive_paradigm_cogatlas=cog_atlas_id,
                                             collection__private=False).order_by("pk")
        
        if len(images) > 0:
            first_image = images[0]
            graph = get_task_graph(cog_atlas_id, images=images)

            # Which images aren't tagged with contrasts?
            not_tagged = images.filter(cognitive_contrast_cogatlas__isnull=True)

            context = {'task': task,
                       'first_image': first_image,
                       'cognitive_atlas_tree': graph,
                       'tree_divid': "tree",  # div id in template to append tree svg to
                       'images_without_contrasts': not_tagged}

            return render(request, 'cogatlas/cognitive_atlas_task.html', context)

    # If task does not have images   
    context = {"no_task_images": True, # robots won't index page if defined
               "task": task } 
    return render(request, 'cogatlas/cognitive_atlas_task.html', context)
dataset/ETHPy150Open NeuroVault/NeuroVault/neurovault/apps/statmaps/views.py/view_task