Code Monkey home page Code Monkey logo

Comments (9)

byvernault avatar byvernault commented on July 30, 2024

hmm ... I am trying to remember in which case I am using this method.

I think this is used in the case of scan spiders only. It was created to help the user check that the assessor with a prototype and the a scan is unusable or not. E.G: bedpost checking for dtiQA (same scan) if I remember. It shouldn't be used for checking a session_processor status.

I am not sure I see in which case you want to use this for a session processor.

from dax.

damonms avatar damonms commented on July 30, 2024

Bedpost with DTIQA multi.


From: Benjamin Yvernault [[email protected]]
Sent: Monday, February 15, 2016 12:02 PM
To: VUIIS/dax
Cc: Damon, Stephen M
Subject: Re: [dax] is_assessor_same_scan_unusable is broken for session processors (#48)

hmm ... I am trying to remember in which case I am using this method.

I think this is used in the case of scan spiders only. It was created to help the user check that the assessor with a prototype and the a scan is unusable or not. E.G: bedpost checking for dtiQA (same scan) if I remember. It shouldn't be used for checking a session_processor status.

I am not sure I see in which case you want to use this for a session processor.


Reply to this email directly or view it on GitHubhttps://github.com//issues/48#issuecomment-184327941.

from dax.

byvernault avatar byvernault commented on July 30, 2024

In that case, It's not on the same scan since it's an assessor on the session.
I would see the processor run() like :

If assessor_dtiqa_multi.exists() and XnatUtils.is_assessor_usable(assessor_dtiqa_multi):
return ...
elif XnatUtils.is_assessor_same_scan_unusable(cscan, proctype):
return ...

I see what you want to do and I agree we should add that by either creating a new function (we don't have to) or just rename the function and add you're idea of the flag and probably call the function :
is_assessor_on_same_session_unusable(cscan, proctype)

The function will work in both case. Maybe something that is then more generic.
What do you think?

Cheers,

Ben

from dax.

byvernault avatar byvernault commented on July 30, 2024

Hey Steve,

What do you think about something like this:

    def is_assessor_on_same_session_unusable(cobj, proctype, is_scan_proc=False):
        """
        Check to see if the assessor matching the user passed scan and proctype has
         passed QC.
        :param cob: CachedImage object from XnatUtils (scan/session)
        :param proctype: Process type of the assessor to check
        :param is_scan_proc: if the processor is a scan level processor
        :return: 0 if the assessor is not ready or doesn't exist. -1 if it failed,
         or 1 if OK
        """
        obj_info = cobj.info()
        assr_list = list()
        if isinstance(cobj, 'CachedImageScan'):
            if is_scan_proc:
                assr_label = '-x-'.join([obj_info['project_id'], obj_info['subject_label'], obj_info['session_label'], obj_info['ID'], proctype])
            else:
                assr_label = '-x-'.join([obj_info['project_id'], obj_info['subject_label'], obj_info['session_label'],  proctype])
                assr_list = [cassr.info() for cassr in cobj.parent().assessors() if cassr.info()['label'] == assr_label]
        elif isinstance(cobj, 'CachedImageSession'):
            assr_list = [cassr.info() for cassr in cobj.assessors() if cassr.info()['proctype'] == proctype]

        if not assr_list:
            return 0
        elif len(assr_list) == 1:
            return is_bad_qa(assr_list[0]['qcstatus'])
        else:
            # too many assessors checked if one rdy??
            good_assr_list = [assr_info['label'] for assr_info in assr_list if is_bad_qa(assr_info['qcstatus']) == 1]
            if len(good_assr_list) == 1:
                return 1
            elif len(good_assr_list) > 1:
                print "WARNING: too many assessors %s with a good QC status." % (proctype)
                return 0
        return 0

The one thing I am not sure yet is that if there is more than one assessor in the list found with the proctype (e.g: two dtiQA on a session for a session assessor that is checking on dtiQA). Maybe check if only one is good if not let the user know.

Let me know what you think,

Cheers,

Ben

from dax.

damonms avatar damonms commented on July 30, 2024

I like it. I was also thinking about the case of multiple assessors. Two thoughts here: 1) Returns the list and make the user filter further. 2) Or give an optional list of scan types? This could also still have the case of multiple hits for certain projects with multiple fMRI runs of the same type.

from dax.

byvernault avatar byvernault commented on July 30, 2024

hmmm, we could also separate this function in two:

  1. one to return the list of cassr from a cobj (scan or session) where we give the proctype we want to search for.
  2. change the code to get the assr_list in the previous method.

Something like:

def get_cassr_on_same_session(cobj, proctype, is_scan_proc=False):
    """
    Get the list of all assessors with the proctype given for a cobj (session, scan)

    :param cobj: CachedImage object from XnatUtils (scan/session)
    :param proctype: Process type of the assessor to check
    :param is_scan_proc: if the processor is a scan level processor
    :return: list of CachedImageAssessor objects
    """
    obj_info = cobj.info()
    cassr_list = list()
    if isinstance(cobj, 'CachedImageScan'):
        if is_scan_proc:
            assr_label = '-x-'.join([obj_info['project_id'], obj_info['subject_label'], obj_info['session_label'], obj_info['ID'], proctype])
        else:
            assr_label = '-x-'.join([obj_info['project_id'], obj_info['subject_label'], obj_info['session_label'],  proctype])
        cassr_list = [cassr for cassr in cobj.parent().assessors() if cassr.info()['label'] == assr_label]
    elif isinstance(cobj, 'CachedImageSession'):
        cassr_list = [cassr for cassr in cobj.assessors() if cassr.info()['proctype'] == proctype]
    return cassr_list

def is_assessor_on_same_session_usable(cobj, proctype, is_scan_proc=False):
    """
    Check to see if the assessor matching the user passed scan and proctype has
     passed QC.

    :param cobj: CachedImage object from XnatUtils (scan/session)
    :param proctype: Process type of the assessor to check
    :param is_scan_proc: if the processor is a scan level processor
    :return: 0 if the assessor is not ready or doesn't exist. -1 if it failed,
     or 1 if OK
    """
    cassr_list = get_cassr_on_same_session(cobj, proctype, is_scan_proc)

    if not cassr_list:
        return 0
    elif len(cassr_list) == 1:
        return is_bad_qa(cassr_list[0].info()['qcstatus'])
    else:
        # too many assessors checked if one rdy??
        good_cassr_list = [cassr.info() for cassr in cassr_list if is_bad_qa(cassr.info()['qcstatus']) == 1]
        if len(good_cassr_list) == 1:
            return 1
        elif len(good_cassr_list) > 1:
            print "WARNING: too many assessors %s with a good QC status." % (proctype)
            return 0
    return 0

Then users can just get all the assessor good for the cobj and do what they want with it or just use the is_assessor .... function to know if the assessor is good or no.

For the scan type, you mean give a list of proctypes for the scan level processor?

from dax.

damonms avatar damonms commented on July 30, 2024

I like it!


From: Benjamin Yvernault [[email protected]]
Sent: Tuesday, February 16, 2016 9:36 AM
To: VUIIS/dax
Cc: Damon, Stephen M
Subject: Re: [dax] is_assessor_same_scan_unusable is broken for session processors (#48)

hmmm, we could also separate this function in two:

  1. one to return the list of cassr from a cobj (scan or session) where we give the proctype we want to search for.
  2. change the code to get the assr_list in the previous method.

Something like:

def get_cassr_on_same_session(cobj, proctype, is_scan_proc=False):
"""
Get the list of all assessors with the proctype given for a cobj (session, scan)

:param cobj: CachedImage object from XnatUtils (scan/session)
:param proctype: Process type of the assessor to check
:param is_scan_proc: if the processor is a scan level processor
:return: list of CachedImageAssessor objects
"""
obj_info = cobj.info()
cassr_list = list()
if isinstance(cobj, 'CachedImageScan'):
    if is_scan_proc:
        assr_label = '-x-'.join([obj_info['project_id'], obj_info['subject_label'], obj_info['session_label'], obj_info['ID'], proctype])
    else:
        assr_label = '-x-'.join([obj_info['project_id'], obj_info['subject_label'], obj_info['session_label'],  proctype])
    cassr_list = [cassr for cassr in cobj.parent().assessors() if cassr.info()['label'] == assr_label]
elif isinstance(cobj, 'CachedImageSession'):
    cassr_list = [cassr for cassr in cobj.assessors() if cassr.info()['proctype'] == proctype]
return cassr_list

def is_assessor_on_same_session_usable(cobj, proctype, is_scan_proc=False):
"""
Check to see if the assessor matching the user passed scan and proctype has
passed QC.

:param cobj: CachedImage object from XnatUtils (scan/session)
:param proctype: Process type of the assessor to check
:param is_scan_proc: if the processor is a scan level processor
:return: 0 if the assessor is not ready or doesn't exist. -1 if it failed,
 or 1 if OK
"""
cassr_list = get_cassr_on_same_session(cobj, proctype, is_scan_proc)

if not cassr_list:
    return 0
elif len(cassr_list) == 1:
    return is_bad_qa(cassr_list[0].info()['qcstatus'])
else:
    # too many assessors checked if one rdy??
    good_cassr_list = [cassr.info() for cassr in cassr_list if is_bad_qa(cassr.info()['qcstatus']) == 1]
    if len(good_cassr_list) == 1:
        return 1
    elif len(good_cassr_list) > 1:
        print "WARNING: too many assessors %s with a good QC status." % (proctype)
        return 0
return 0


Reply to this email directly or view it on GitHubhttps://github.com//issues/48#issuecomment-184733212.

from dax.

byvernault avatar byvernault commented on July 30, 2024

Ok doing a push request for that.

from dax.

damonms avatar damonms commented on July 30, 2024

Done

from dax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.