robbert-harms / MDT

Microstructure Diffusion Toolbox
GNU Lesser General Public License v3.0
50 stars 18 forks source link

Initialization #43

Closed StefaniaOliviero closed 2 years ago

StefaniaOliviero commented 2 years ago

Hi all, I created two new models for microstructure (Model A and Model B). I would like to implement the following steps: 1 to fit a signal (map) with Model A, to obtain the map of its parameters A.p1, A.p2, A.p3 2 to fit the same signal (map) with Model B, to obtain the map of its parameters B.p1, B.p2, B.p3, B.p4; 2.1 in this second fit process I need to FIX the map of the parameter B.p1 with the map of the parameter A.p1. Is there any way to do this?

Thanks a lot in advance

robbert-harms commented 2 years ago

Hi Stefania,

This is very well possible, although only from within Python code. Please have a look at this code I wrote some time ago for Axcaliber fitting:


charmed_results = mdt.fit_model(
    'CHARMED_r1',
    mdt.load_input_data(
        pjoin('charmed_data'),
        pjoin('charmed_protocol.prtcl'),
        pjoin('mask')
    ),
    pjoin('output', 'charmed_data'))

axcaliber_results = mdt.fit_model(
    'AxCaliber',
    mdt.load_input_data(
        pjoin('axcaliber_data'),
        pjoin('axcaliber_protocol.prtcl'),
        pjoin('mask')
    ),
    pjoin('output', 'axcaliber_data'),
    initialization_data={
        'fixes': {
            'GDRCylinders.d': charmed_results['CHARMEDRestricted0.d']
            ...
        },
        'inits': {
            'Tensor.d': charmed_results['Tensor.d'],
            ...
        }
    })

The idea is that within the argument "initialization_data" you can provide initializations and fixations of model parameters using results from previous models.

I hope this helps, let me know if this was not very informative.

Best,

Robbert

StefaniaOliviero commented 2 years ago

Thanks a lot Robbert! I closed the issue with your suggestion :)