Different End Cases Between LCMGUI & LCModel command line

Hello Everyone,

I’m relatively new to the community and am looking to streamline the mrsi pipeline for my lab. One important step for this is getting the LCModel fit results. I have been manually doing this through the lcmgui, however, it would be even faster if I can do it through the command line. However, when I began using control files to run LCModel through command lines rather than the GUI, I noticed a discrepancy between my outputs.

When I run LCModel using the command line, LCModel terminates earlier than it does with the GUI. I.e. both methods perform and get equal results from fitting the center voxels, but as the program moves onto the outer voxels the command line method terminates earlier even for my best quality data. Is there a command that I can input into my control file to prevent early termination? I’m aware that LCMGUI uses the standard execution script with the line MAX_BAD =16 to describe the end case for bad voxels, is there a way to do this within the control files for the command line input?

TLDR: How can I change my control file for LCModel use through the command line so that it can skip the same number of bad voxels as LCMGUI.

I can reply with my control files (input for command line and output from lcmgui) if they would help.

Best,
Yeison Rodriguez

I’m actually just going to post the control files to save everyone’s time:

Control File 1 - used as input to ubuntu (through WSL) command line:
$LCMODL
OWNER = ‘Yeison @ Henning Lab’
filbas = ‘/home/s208931/.lcmodel/basis-sets/9T_FID.basis’
filps = ‘/home/s208931/.lcmodel/saved/Volunteer1_MAT_sl1/ps’
filtab = ‘/home/s208931/.lcmodel/saved/Volunteer1_MAT_sl1/table’
key = 210387309
filraw = ‘/home/s208931/.lcmodel/agora_files/9.4TData/Volunteer1_MAT_sl1_Met’
dows = F
doecc = F
Title = ‘Volunteer1_MAT_sl1’
ltable = 7
lps = 8
degzer = 0
deltaT = 1.2500e-04
hzpppm = 399.79
icolen = 43
icolst = 10
irowen = 43
irowst = 10
islice = 1
ndcols = 48
ndrows = 48
ndslic = 1
neach = 50
nsimul = 0
nunfil = 4096
ppmend = 1.0
ppmst = 4.2
$END

Control File 2 - Outputted in the results file after processing with the GUI:
$LCMODL
title= ‘’
srcraw= ‘/home/s208931/.lcmodel/agora_files/9.4TData/Volunteer1_MAT_sl1_Met’
savdir= ‘/home/s208931/.lcmodel/saved/Vol1_sl1_LCMGUI/’
ppmst= 4.2
ppmend= 1.0
nunfil= 4096
nsimul= 0
neach= 50
ndslic= 1
ndrows= 48
ndcols= 48
ltable= 7
lps= 8
lprint= 6
lcsv= 11
lcoraw= 10
lcoord= 9
key= 210387309
islice= 1
irowst= 10
irowen= 43
icolst= 10
icolen= 43
hzpppm= 399.79
filtab= ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/table’
filraw= ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/met/RAW’
filps= ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/ps’
filpri= ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/print’
filcsv= ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/spreadsheet.csv’
filcor= ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/coraw’
filcoo= ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/coord’
filbas= ‘/home/s208931/.lcmodel/basis-sets/9T_FID.basis’
deltat= 1.2500e-04
lcsi_sav_1 = 12, filcsi_sav_1 = ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/filcsi_sav_1’, lcsi_sav_2 = 13, filcsi_sav_2 = ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/filcsi_sav_2’
$END

These are the three main differences between the two control files that I can spot at first glance.
dows = F and doecc = F are the flags to deactivate water scaling and eddy-current correction, but I don’t see a water reference file provided (do you have one at all that you use?) anyway, so they shouldn’t matter much.

degzer = 0 might matter though (it’s a zero-order phase correction prior). I think the default for that is 0 anyway, but you never know what’s going on behind the scenes with LCModel.

edit: lcoraw = 10 is also different but I have not really used that before - see the manual at section 11.9.3.

MAX_BAD isn’t specified in the control file. Looking closely at the run script (execution-scripts/standard), it’s basically running LCModel multiple times (up to MAX_BAD times) with the same control file.

The magic, I think, is these two lines:

lcsi_sav_1 = 12, filcsi_sav_1 = ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/filcsi_sav_1’ 
lcsi_sav_2 = 13, filcsi_sav_2 = ‘/home/s208931/.lcmodel/temp/11d-14h-42m-03s-17458pid/filcsi_sav_2’

lcsi_sav isn’t documented, but appears to specify a temporary file which LCModel can use to store state between successive runs. So, it remembers how far it got before failing, and picks up on the next voxel the next time you call it.

The safest would be to use the supplied execution script (lcmodel/execution-scripts/standard), since this initialises the files correctly and handles edge cases (like failure on the first voxel) sensibly.

I suggest, for each subject:

  • Create a temporary folder:
    temp_folder=$(mktemp -d)
  • Copy your original control file to that folder (needs to be named, exactly, control ):
    cp your.control.file ${temp_folder}/control
  • Then run the execution script on that folder,
    lcmodel/execution-scripts/standard ${temp_folder}
  • Then, clean up the temporary folder:
    rm -f ${temp_folder}/{filcsi_sav_2,filcsi_sav_1,control,runtime-messages,times}; rmdir ${temp_folder}/done ${temp_folder}

Hey,
Thank you for the response. I see that the second control file doesn’t contain the dows & doecc bools, but they were set to false/not activated in the gui and I don’t have a water file for this dataset so it shouldn’t be the difference. It is there in the first file because some of my datasets contain a water reference file, so my write function writes these variables.
As for lcoraw, I excluded it from the control files that I write (vs LCMGUI) because right now I am still testing the functionality, so I am just keeping the basic output that I need. It also is unlikely to be the error because both options produce the same output for a portion of the range, e.g. from 15:40 row/col, but the command line option will terminate about 5 rows earlier (not set but dependent on data set).
You raise a good point with the zero-order prior correction. However, I’ve rerun the data with both methods excluding the variable and I still observe the same effect. I wonder if this is just something that is hard coded in the LCModel Fortran code and that is why the execution scripts were developed to modify the code.

Hey Alex,

Thanks for the suggestions, I suspected it might have something to do with myself saving directly to a different directory and bypassing the temporary folder. But as you mentioned in your last point, I’ve cleared the temporary folder before, and it can cause issues with LCModel so I figured it was best to avoid writing/reading from here. However, the reasoning is logical and would explain the difference. I will try these suggestions today after making a clone, Thanks!