Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should there ever be a need to do file filtering on a stream contents? #19

Closed
rhodricusack opened this issue Apr 15, 2012 · 18 comments
Closed
Labels

Comments

@rhodricusack
Copy link
Collaborator

I had imagined that a stream would uniquely identify all, and only, the files of a particular kind. So, the "structural" (or soon to be "T1") stream would only contain normalized images after normalization, and so on.

However, for the purpose of setting up bet, Sasha added the following into the structural stream during aamod_norm_noss:

  • unnormalized structural
  • bias corrected structural image (mm*)
  • warped structural image (w*)

Now, he and I agreed that there's no need to have the unnormalized, because if one wants, one can use the fully specified syntax in a tasklist or .xml module wrapper
aamod_copystructural.structural
to get to the previous data. So, we took this out.

However, now I'm running into a problem that the aamod_bet_modified module filters for the "mm" image, rather than taking the "w, which is what I want to run it on. By re-including file filtering within the aamod_bet_modified module, we've made it more difficult to change what a module works on by just changing its order. If you want bet to run on the data before normalization, then you put it before norm_noss; if you want it after, you put it afterwards.

I would suggest that we try to avoid file filtering for this reason. We could either write a separate bias correction module before normalization, or write this to a separate stream (T1_biascorr or something)?

@jpeelle
Copy link
Member

jpeelle commented Apr 15, 2012

I think a separate module makes sense. In fact, I already started to do this as part of the "new segment"/VBM pipeline, which also previously used file filtering and combined bias correction and segmentation. Having a separate module gives users much more flexibility all around, which I think is a good thing.

@alexvicegrab
Copy link
Collaborator

Sorry about the issue, I just had imagined that BET should work best on a native brain, which is why I implemented the filtering in the first case. But indeed, a flexible pipeline is best for everyone, I completely agree on a separate module for bias correction, which would be useful in other places!

@alexvicegrab
Copy link
Collaborator

I have fixed aamod_bet_robust, so that it typically considers the first structural, but such that this really depends on a variable in the .xml, which can be changed at the recipe level. Now we only need a module for bias correction :-)

@alexvicegrab
Copy link
Collaborator

Oh, and am fixing it also in aamod_bet_modified
What do we do with the filtering in aamod_bet_epi_reslicing? I guess we don't need filtering there either?

@rhodricusack
Copy link
Collaborator Author

Isn't aamod_bet_modified + aamod_bet_epi_reslicing = aamod_bet_robust
Can we tidy up by deleting the latter??

On 17 April 2012 10:39, alexvicegrab <
reply@reply.github.com

wrote:

Oh, and am fixing it also in aamod_bet_modified
What do we do with the filtering in aamod_bet_epi_reslicing? I guess we
don't need filtering there either?


Reply to this email directly or view it on GitHub:

#19 (comment)

Rhodri Cusack
www.cusacklab.org

Associate Professor
Brain and Mind Institute
Natural Sciences Centre, Room 203
The University of Western Ontario
London, Ontario N6A 5B7
CANADA
+1 519 661 2111 ext 86381

@alexvicegrab
Copy link
Collaborator

I have changed aamod_bet_robust to not do reslicing. It still has a number of options that make it more complete than the aamod_bet_modified, which include masking out the neck (by masking using the SPM T1 template) and doing bias correction (though this should be moved to a separate module, as we have discussed already). We may want to move the neck masking out as well?

Also, aamod_bet seems to have changed to resemble aamod_bet_robust, which is strange. Maybe we should collapse aamod_bet_robust into the aamod_bet, but add an option for the 'robustness' bit? What do you think?

@jpeelle
Copy link
Member

jpeelle commented Apr 17, 2012

Giving my 2 cents without having used the bet functions (!): having a single aamod_bet with the option to set multiple parameters (i.e. akin to command line options) seems the most elegant.

@rhodricusack
Copy link
Collaborator Author

That could be aamod_bet. Then, we could have one other option, that
includes Sasha's more exotic multi-pass strategy (which worked very well on
the Cam CAN data, in a fairly broad comparison with lots of different bet
parameters).

On 17 April 2012 13:41, Jonathan Peelle <
reply@reply.github.com

wrote:

Giving my 2 cents without having used the bet functions (!): having a
single aamod_bet with the option to set multiple parameters (i.e. akin to
command line options) seems the most elegant.


Reply to this email directly or view it on GitHub:

#19 (comment)

Rhodri Cusack
www.cusacklab.org

Associate Professor
Brain and Mind Institute
Natural Sciences Centre, Room 203
The University of Western Ontario
London, Ontario N6A 5B7
CANADA
+1 519 661 2111 ext 86381

@alexvicegrab
Copy link
Collaborator

I have now made a trial aamod_bet with 3 options:
robust (0 or 1) % multipass or not?
masks (0 or 1) % do we make BET masks after the initial pass or not?
structural (typically 1) % which structural, if there's more than 1, do we use for BETting

Also made a bet_premask module, which removes neck using the T1_template from the structural, which we can run before BET.

We could do bias correction at any point before/after/inbetween?

Does that sound like a plan?

@rhodricusack
Copy link
Collaborator Author

Sounds great! The script that worked well for Vivek & I on the CamCAN data
is below - looks like multipass=1 masks=1 structural=1?

% AA module
% Runs BET on structural

function [aap,resp]=aamod_bet(aap,task,i)

resp='';

switch task
case 'summary'
subjpath=aas_getsubjpath(i);
resp=sprintf('Align %s\n',subjpath);

case 'report'

case 'doit'

    warning off

    tic

    % Let us use the native space...
    Sfn = aas_getfiles_bystream(aap,i,'structural');

    % Cheap and cheerful way of ensuring only one file is considered!
    if size(Sfn,1) > 1
        for a = 1:size(Sfn,1)
            % Not warped or betted!
            if ~strcmp(Sfn(a,1), 'w') && ~strcmp(Sfn(a,1), 'b')
                Sfn = Sfn(a,:);
                break
            end
        end
        fprintf('\tSeveral structurals found, considering: %s\n', Sfn)
    end


    [pth nme ext]=fileparts(Sfn);

    outStruct=fullfile(pth,['bet_' nme ext]);
    % Run BET [-R Using robust setting to avoid neck!]
    fprintf('Initial BET pass (recursive) to find optimal centre of

gravity\n')
[~, w]=aas_runfslcommand(aap, ...
sprintf('bet %s %s -f %f -v -R',Sfn,outStruct, ...
aap.tasklist.currenttask.settings.bet_f_parameter));

    % This outputs last centre of gravity from recursive command...
    indxS = strfind(w, 'c-of-g');
    indxS = indxS(end) + 7;
    indxE = strfind(w(indxS:end), 'mm');
    indxE = indxE(1) - 3;
    COG = w(indxS:indxS+indxE);

    fprintf('Second BET pass extracting also brain masks\n')
    % Run BET [-A Now let's get the brain masks and meshes!!]
    [~, w]=aas_runfslcommand(aap, ...
        sprintf('bet %s %s -f %f -c %s -v -A',Sfn,outStruct, ...
        aap.tasklist.currenttask.settings.bet_f_parameter, COG)...
        );


    % Find the mask images
    D = dir(fullfile(pth, 'bet*mask*'));
    outMask = '';
    for d = 1:length(D)
        outMask = strvcat(outMask, fullfile(pth, D(d).name));
    end

    % Find the meshes
    D = dir(fullfile(pth, 'bet*mesh*'));
    outMesh = '';
    for d = 1:length(D)
        outMesh = strvcat(outMesh, fullfile(pth, D(d).name));
    end



    % DESCRIBE OUTPUTS!
    % Structural image after BETting
    aap=aas_desc_outputs(aap,i,'structural',outStruct);
    aap=aas_desc_outputs(aap,i,'BETmask',outMask);
    aap=aas_desc_outputs(aap,i,'BETmesh',outMesh);

    time_elapsed

end

On 17 April 2012 13:57, alexvicegrab <
reply@reply.github.com

wrote:

I have now made a trial aamod_bet with 3 options:
robust (0 or 1) % multipass or not?
masks (0 or 1) % do we make BET masks after the initial pass or not?
structural (typically 1) % which structural, if there's more than 1, do we
use for BETting

Also made a bet_premask module, which removes neck using the T1_template
from the structural, which we can run before BET.

We could do bias correction at any point before/after/inbetween?

Does that sound like a plan?


Reply to this email directly or view it on GitHub:

#19 (comment)

Rhodri Cusack
www.cusacklab.org

Associate Professor
Brain and Mind Institute
Natural Sciences Centre, Room 203
The University of Western Ontario
London, Ontario N6A 5B7
CANADA
+1 519 661 2111 ext 86381

@alexvicegrab
Copy link
Collaborator

Cool! I'll commit the changes once I get the dependency stats to work (see issue 21) :-)

@jpeelle
Copy link
Member

jpeelle commented Apr 17, 2012

This all sounds good. Would it make sense to specify the file stream in the xml header? I.e. usually this would be 'structural' [1], but someone may want to, for example, average 2 T1 images and then perform bet on a different file stream (e.g. 'meant1'), or try using bet on a t2 image, etc.

Thus in the xml file we would have

structural

and in the script

aas_getfiles_bystream(aap,i,aap.tasksettings.currenttask.filestream);

or something like that.

Does that make sense?

(If so, this may be worth incorporating in some other modules...)

[1] soon to be 't1' - I hope to do this today or tomorrow

@jpeelle
Copy link
Member

jpeelle commented Apr 17, 2012

Oops, error parsing that. Should have been:

Thus in the xml file we would have

<filestream>structural</filestream>

and in the script

aas_getfiles_bystream(aap,i,aap.tasksettings.currenttask.filestream);

or something like that.

@rhodricusack
Copy link
Collaborator Author

Hi! This is possible within the current framework in two ways:
(1) have a module that takes as input the two structurals (or T1s) for
meaning and outputs a single structural?
(2) insert aamod_mapstreams - this takes one or more input streams and maps
them onto the same number of outputstreams...
This latter probably does what you need? What do you think?

On 17 April 2012 14:33, Jonathan Peelle <
reply@reply.github.com

wrote:

Oops, error parsing that. Should have been:

Thus in the xml file we would have

structural

and in the script

aas_getfiles_bystream(aap,i,aap.tasksettings.currenttask.filestream);

or something like that.


Reply to this email directly or view it on GitHub:

#19 (comment)

Rhodri Cusack
www.cusacklab.org

Associate Professor
Brain and Mind Institute
Natural Sciences Centre, Room 203
The University of Western Ontario
London, Ontario N6A 5B7
CANADA
+1 519 661 2111 ext 86381

@jpeelle
Copy link
Member

jpeelle commented Apr 17, 2012

Hi Rhodri,

That all seems fine for now - I don't actually have any cases where this wouldn't work. I'm just thinking ahead in terms of what might be handy in the future.

For example, I would like to make the bias-correction/segmentation functions accept one or more filestreams (t1 vs. t1+t2). I think that's pretty do-able, I just didn't know if it would make sense to incorporate this flexibility elsewhere.

@rhodricusack
Copy link
Collaborator Author

Ah! I'm sorry, I misunderstood - I get it now. I was thinking you were
changing the section of the header, rather than having a
separate field.

Where there is only one stream, or where the same things happen to all of
the streams, then it is possible to iterate through the and
ask for them all, in which case it is a bit like your suggestion, but
without the extra field. An example of this is in:
https://github.com/rhodricusack/automaticanalysis/blob/master/aa_modules/aamod_smooth.m

However, in the case where there are input streams that have different
intents, I like your suggestion!
Rhodri

On 17 April 2012 15:37, Jonathan Peelle <
reply@reply.github.com

wrote:

Hi Rhodri,

That all seems fine for now - I don't actually have any cases where this
wouldn't work. I'm just thinking ahead in terms of what might be handy in
the future.

For example, I would like to make the bias-correction/segmentation
functions accept one or more filestreams (t1 vs. t1+t2). I think that's
pretty do-able, I just didn't know if it would make sense to incorporate
this flexibility elsewhere.


Reply to this email directly or view it on GitHub:

#19 (comment)

Rhodri Cusack
www.cusacklab.org

Associate Professor
Brain and Mind Institute
Natural Sciences Centre, Room 203
The University of Western Ontario
London, Ontario N6A 5B7
CANADA
+1 519 661 2111 ext 86381

@jpeelle
Copy link
Member

jpeelle commented Apr 17, 2012

Great, thanks - that's very helpful.

tiborauer pushed a commit that referenced this issue Oct 20, 2017
DEBUG/UPDATE: aas_addsubject help
@jpeelle
Copy link
Member

jpeelle commented Apr 18, 2018

Closing this issue for now but agree we should keep an eye on this issue (ongoing in issue #69).

@jpeelle jpeelle closed this as completed Apr 18, 2018
jpeelle pushed a commit that referenced this issue Jul 9, 2019
DEBUG: secondlevel threshold without structural can find template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants